Skip to content

Commit 53da93c

Browse files
konardclaude
andcommitted
Implement GoogleSearchErrorTrigger for issue #65
Add functionality to detect gist.github.com and pastebin.com URLs in GitHub issues, extract error messages from their content, and provide Google search links to whitelisted sites for potential solutions. Features: - Detects gist and pastebin URLs in issue titles and bodies - Extracts various error patterns (exceptions, compilation errors, runtime errors) - Searches Google with site-specific filters for whitelisted domains - Provides helpful search links in issue comments - Includes basic unit tests and example documentation Whitelisted domains: stackoverflow.com, github.com, docs.microsoft.com, developer.mozilla.org, msdn.microsoft.com, programmingpedia.com, geeksforgeeks.org 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 8d9d03b commit 53da93c

File tree

8 files changed

+567
-1
lines changed

8 files changed

+567
-1
lines changed

Bot.sln

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3+
#
34
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Platform.Bot", "csharp\Platform.Bot\Platform.Bot.csproj", "{81D55AD3-9698-4BEC-B7EC-26ED7B8E6E53}"
45
EndProject
56
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FileManager", "csharp\FileManager\FileManager.csproj", "{2F40CB1A-A1FD-4433-B998-BC3AEA2EFEB3}"
@@ -10,6 +11,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Storage", "csharp\Storage\S
1011
EndProject
1112
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TraderBot", "csharp\TraderBot\TraderBot.csproj", "{FAE89FE2-17C5-4AD6-98EC-84002CC4C672}"
1213
EndProject
14+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "csharp", "csharp", "{5B274C13-EB2B-4612-9430-26107BEFA67F}"
15+
EndProject
16+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Platform.Bot.Tests", "csharp\Platform.Bot.Tests\Platform.Bot.Tests.csproj", "{F3D39934-E504-4B61-91DB-B37F654B7925}"
17+
EndProject
1318
Global
1419
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1520
Debug|Any CPU = Debug|Any CPU
@@ -36,5 +41,12 @@ Global
3641
{FAE89FE2-17C5-4AD6-98EC-84002CC4C672}.Debug|Any CPU.Build.0 = Debug|Any CPU
3742
{FAE89FE2-17C5-4AD6-98EC-84002CC4C672}.Release|Any CPU.ActiveCfg = Release|Any CPU
3843
{FAE89FE2-17C5-4AD6-98EC-84002CC4C672}.Release|Any CPU.Build.0 = Release|Any CPU
44+
{F3D39934-E504-4B61-91DB-B37F654B7925}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
45+
{F3D39934-E504-4B61-91DB-B37F654B7925}.Debug|Any CPU.Build.0 = Debug|Any CPU
46+
{F3D39934-E504-4B61-91DB-B37F654B7925}.Release|Any CPU.ActiveCfg = Release|Any CPU
47+
{F3D39934-E504-4B61-91DB-B37F654B7925}.Release|Any CPU.Build.0 = Release|Any CPU
48+
EndGlobalSection
49+
GlobalSection(NestedProjects) = preSolution
50+
{F3D39934-E504-4B61-91DB-B37F654B7925} = {5B274C13-EB2B-4612-9430-26107BEFA67F}
3951
EndGlobalSection
4052
EndGlobal
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using System.Threading.Tasks;
2+
using Moq;
3+
using Platform.Bot.Triggers;
4+
using Storage.Remote.GitHub;
5+
using Xunit;
6+
7+
namespace Platform.Bot.Tests
8+
{
9+
/// <summary>
10+
/// <para>
11+
/// Tests for the GoogleSearchErrorTrigger class.
12+
/// </para>
13+
/// <para></para>
14+
/// </summary>
15+
public class GoogleSearchErrorTriggerTests
16+
{
17+
/// <summary>
18+
/// <para>
19+
/// Tests that the trigger can be instantiated without errors.
20+
/// </para>
21+
/// <para></para>
22+
/// </summary>
23+
[Fact]
24+
public void Constructor_WithValidStorage_CreatesInstance()
25+
{
26+
// Arrange
27+
var mockStorage = new Mock<GitHubStorage>("testuser", "testtoken", "testapp");
28+
29+
// Act
30+
var trigger = new GoogleSearchErrorTrigger(mockStorage.Object);
31+
32+
// Assert
33+
Assert.NotNull(trigger);
34+
}
35+
36+
/// <summary>
37+
/// <para>
38+
/// Tests that the class has the expected public methods.
39+
/// </para>
40+
/// <para></para>
41+
/// </summary>
42+
[Fact]
43+
public void PublicMethods_AreAvailable()
44+
{
45+
// Arrange
46+
var mockStorage = new Mock<GitHubStorage>("testuser", "testtoken", "testapp");
47+
var trigger = new GoogleSearchErrorTrigger(mockStorage.Object);
48+
49+
// Act & Assert - Just verify methods exist and can be called
50+
Assert.NotNull(trigger.GetType().GetMethod("Condition"));
51+
Assert.NotNull(trigger.GetType().GetMethod("Action"));
52+
Assert.NotNull(trigger.GetType().GetMethod("Dispose"));
53+
}
54+
}
55+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<IsPackable>false</IsPackable>
7+
<IsTestProject>true</IsTestProject>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
12+
<PackageReference Include="xunit" Version="2.4.2" />
13+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
14+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
15+
<PrivateAssets>all</PrivateAssets>
16+
</PackageReference>
17+
<PackageReference Include="Moq" Version="4.20.69" />
18+
</ItemGroup>
19+
20+
<ItemGroup>
21+
<ProjectReference Include="..\Platform.Bot\Platform.Bot.csproj" />
22+
</ItemGroup>
23+
24+
</Project>

csharp/Platform.Bot/Platform.Bot.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<PackageReference Include="Platform.Data.Doublets.Sequences" Version="0.1.1" />
1414
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
1515
<PackageReference Include="System.CommandLine.Parser" Version="0.1.1" />
16+
<PackageReference Include="System.Text.Json" Version="8.0.5" />
1617
</ItemGroup>
1718

1819
<ItemGroup>

csharp/Platform.Bot/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ private static async Task<int> Main(string[] args)
9595
var dbContext = new FileStorage(databaseFilePath?.FullName ?? new TemporaryFile().Filename);
9696
Console.WriteLine($"Bot has been started. {Environment.NewLine}Press CTRL+C to close");
9797
var githubStorage = new GitHubStorage(githubUserName, githubApiToken, githubApplicationName);
98-
var issueTracker = new IssueTracker(githubStorage, new HelloWorldTrigger(githubStorage, dbContext, fileSetName), new OrganizationLastMonthActivityTrigger(githubStorage), new LastCommitActivityTrigger(githubStorage), new AdminAuthorIssueTriggerDecorator(new ProtectDefaultBranchTrigger(githubStorage), githubStorage), new AdminAuthorIssueTriggerDecorator(new ChangeOrganizationRepositoriesDefaultBranchTrigger(githubStorage, dbContext), githubStorage), new AdminAuthorIssueTriggerDecorator(new ChangeOrganizationPullRequestsBaseBranchTrigger(githubStorage, dbContext), githubStorage));
98+
var issueTracker = new IssueTracker(githubStorage, new HelloWorldTrigger(githubStorage, dbContext, fileSetName), new GoogleSearchErrorTrigger(githubStorage), new OrganizationLastMonthActivityTrigger(githubStorage), new LastCommitActivityTrigger(githubStorage), new AdminAuthorIssueTriggerDecorator(new ProtectDefaultBranchTrigger(githubStorage), githubStorage), new AdminAuthorIssueTriggerDecorator(new ChangeOrganizationRepositoriesDefaultBranchTrigger(githubStorage, dbContext), githubStorage), new AdminAuthorIssueTriggerDecorator(new ChangeOrganizationPullRequestsBaseBranchTrigger(githubStorage, dbContext), githubStorage));
9999
var pullRequenstTracker = new PullRequestTracker(githubStorage, new MergeDependabotBumpsTrigger(githubStorage));
100100
var timestampTracker = new DateTimeTracker(githubStorage, new CreateAndSaveOrganizationRepositoriesMigrationTrigger(githubStorage, dbContext, Path.Combine(Directory.GetCurrentDirectory(), "/github-migrations")));
101101
var cancellation = new CancellationTokenSource();

0 commit comments

Comments
 (0)