From 788319cbd3508771fd9eec4831e40b11db1040be Mon Sep 17 00:00:00 2001 From: konard Date: Sun, 14 Sep 2025 06:05:50 +0300 Subject: [PATCH 1/3] Initial commit with task details for issue #21 Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: https://github.com/linksplatform/Bot/issues/21 --- CLAUDE.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 00000000..46c6caa5 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,5 @@ +Issue to solve: https://github.com/linksplatform/Bot/issues/21 +Your prepared branch: issue-21-a23bbf98 +Your prepared working directory: /tmp/gh-issue-solver-1757819145675 + +Proceed. \ No newline at end of file From 60e75e3757382c5cb4b684da48ae6a9a065c4b85 Mon Sep 17 00:00:00 2001 From: konard Date: Sun, 14 Sep 2025 06:11:58 +0300 Subject: [PATCH 2/3] Implement welcome message for new users MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add WelcomeMessageTrigger that welcomes first-time issue creators - Add user tracking methods to FileStorage (IsNewUser and MarkUserAsWelcomed) - Include invitations to set languages list, GitHub link, and help command - Integrate WelcomeMessageTrigger into IssueTracker initialization 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- csharp/Platform.Bot/Program.cs | 2 +- .../Triggers/WelcomeMessageTrigger.cs | 88 +++++++++++++++++++ csharp/Storage/LocalStorage/FileStorage.cs | 44 ++++++++++ 3 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 csharp/Platform.Bot/Triggers/WelcomeMessageTrigger.cs diff --git a/csharp/Platform.Bot/Program.cs b/csharp/Platform.Bot/Program.cs index 521a6b95..4d72cf4d 100644 --- a/csharp/Platform.Bot/Program.cs +++ b/csharp/Platform.Bot/Program.cs @@ -95,7 +95,7 @@ private static async Task Main(string[] args) var dbContext = new FileStorage(databaseFilePath?.FullName ?? new TemporaryFile().Filename); Console.WriteLine($"Bot has been started. {Environment.NewLine}Press CTRL+C to close"); var githubStorage = new GitHubStorage(githubUserName, githubApiToken, githubApplicationName); - 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)); + var issueTracker = new IssueTracker(githubStorage, new WelcomeMessageTrigger(githubStorage, dbContext), 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)); var pullRequenstTracker = new PullRequestTracker(githubStorage, new MergeDependabotBumpsTrigger(githubStorage)); var timestampTracker = new DateTimeTracker(githubStorage, new CreateAndSaveOrganizationRepositoriesMigrationTrigger(githubStorage, dbContext, Path.Combine(Directory.GetCurrentDirectory(), "/github-migrations"))); var cancellation = new CancellationTokenSource(); diff --git a/csharp/Platform.Bot/Triggers/WelcomeMessageTrigger.cs b/csharp/Platform.Bot/Triggers/WelcomeMessageTrigger.cs new file mode 100644 index 00000000..a8fd295c --- /dev/null +++ b/csharp/Platform.Bot/Triggers/WelcomeMessageTrigger.cs @@ -0,0 +1,88 @@ +using System.Threading.Tasks; +using Interfaces; +using Octokit; +using Storage.Local; +using Storage.Remote.GitHub; + +namespace Platform.Bot.Triggers +{ + using TContext = Issue; + /// + /// + /// Represents the welcome message trigger for new users. + /// + /// + /// + /// + internal class WelcomeMessageTrigger : ITrigger + { + private readonly GitHubStorage _storage; + private readonly FileStorage _fileStorage; + + /// + /// + /// Initializes a new instance. + /// + /// + /// + /// + /// A GitHub storage. + /// + /// + /// + /// A file storage. + /// + /// + public WelcomeMessageTrigger(GitHubStorage storage, FileStorage fileStorage) + { + this._storage = storage; + this._fileStorage = fileStorage; + } + + /// + /// + /// Actions the context. + /// + /// + /// + /// + /// The context. + /// + /// + public async Task Action(TContext context) + { + var welcomeMessage = @"👋 Welcome to the platform! + +Thank you for creating your first issue. Here are some things you can do to get started: + +🌐 **Set up your languages list**: Let us know which programming languages you're interested in by mentioning them in your issues or profile. + +🔗 **Set up your GitHub link**: Make sure your GitHub profile is properly linked and accessible. + +❓ **Need help?**: Use the `help` command or create an issue with ""help"" in the title to get assistance with available commands and features. + +We're glad to have you here! Feel free to explore and don't hesitate to ask questions."; + + await _storage.CreateIssueComment(context.Repository.Id, context.Number, welcomeMessage); + + // Mark user as welcomed + _fileStorage.MarkUserAsWelcomed(context.User.Login); + } + + /// + /// + /// Determines whether this instance condition. + /// + /// + /// + /// + /// The context. + /// + /// + /// + /// The bool + /// + /// + public async Task Condition(TContext context) => _fileStorage.IsNewUser(context.User.Login); + } +} \ No newline at end of file diff --git a/csharp/Storage/LocalStorage/FileStorage.cs b/csharp/Storage/LocalStorage/FileStorage.cs index aa68fd6f..98495070 100644 --- a/csharp/Storage/LocalStorage/FileStorage.cs +++ b/csharp/Storage/LocalStorage/FileStorage.cs @@ -329,6 +329,50 @@ public List GetFilesFromSet(string set) // public void SetLastGithubMigrationTimeStamp() + /// + /// + /// Checks if a user has been welcomed before. + /// + /// + /// + /// + /// The username to check. + /// + /// + /// + /// True if user is new (not welcomed), false if already welcomed + /// + /// + public bool IsNewUser(string username) + { + var userMarker = CreateString($"welcomed_user:{username}"); + try + { + var existingUser = _synchronizedLinks.SearchOrDefault(userMarker, _synchronizedLinks.Constants.Itself); + return existingUser == _synchronizedLinks.Constants.Null; + } + catch + { + return true; // Assume new user if there's any error + } + } + + /// + /// + /// Marks a user as welcomed. + /// + /// + /// + /// + /// The username to mark as welcomed. + /// + /// + public void MarkUserAsWelcomed(string username) + { + var userMarker = CreateString($"welcomed_user:{username}"); + _synchronizedLinks.GetOrCreate(userMarker, _synchronizedLinks.Constants.Itself); + } + protected override void Dispose(bool manual, bool wasDisposed) { _disposableLinks.Dispose(); From c3467eaa6c4340b09c398b6653e375e8a4a3369e Mon Sep 17 00:00:00 2001 From: konard Date: Sun, 14 Sep 2025 06:12:42 +0300 Subject: [PATCH 3/3] Remove CLAUDE.md - Claude command completed --- CLAUDE.md | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index 46c6caa5..00000000 --- a/CLAUDE.md +++ /dev/null @@ -1,5 +0,0 @@ -Issue to solve: https://github.com/linksplatform/Bot/issues/21 -Your prepared branch: issue-21-a23bbf98 -Your prepared working directory: /tmp/gh-issue-solver-1757819145675 - -Proceed. \ No newline at end of file