From 16961f12d6036bf8573f30c332a35c152423430e Mon Sep 17 00:00:00 2001 From: barelyprofessional <150058423+barelyprofessional@users.noreply.github.com> Date: Sun, 11 May 2025 12:08:43 -0500 Subject: [PATCH] Added git versioning to stamp assemblies with the commit and a command that might work to retrieve the commit hash --- KfChatDotNetBot/Commands/UtilityCommands.cs | 20 +++++++++++++++++++- KfChatDotNetBot/KfChatDotNetBot.csproj | 4 ++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/KfChatDotNetBot/Commands/UtilityCommands.cs b/KfChatDotNetBot/Commands/UtilityCommands.cs index fa7b37e..798d49a 100644 --- a/KfChatDotNetBot/Commands/UtilityCommands.cs +++ b/KfChatDotNetBot/Commands/UtilityCommands.cs @@ -1,4 +1,5 @@ -using System.Text.RegularExpressions; +using System.Reflection; +using System.Text.RegularExpressions; using KfChatDotNetBot.Models.DbModels; using KfChatDotNetWsClient.Models.Events; @@ -50,4 +51,21 @@ public class EnableGambaMessages : ICommand botInstance.BotServices.TemporarilySuppressGambaMessages = false; await botInstance.SendChatMessageAsync("Gamba notifs back on the menu", true); } +} + +public class GetVersionCommand : ICommand +{ + public List Patterns => [ + new Regex("^version$") + ]; + + public string? HelpText => null; + public UserRight RequiredRight => UserRight.Loser; + public TimeSpan Timeout => TimeSpan.FromSeconds(10); + public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx) + { + var version = Assembly.GetEntryAssembly() + .GetCustomAttribute().InformationalVersion; + await botInstance.SendChatMessageAsync($"Bot compiled against {version.Split('+')[1]}", true); + } } \ No newline at end of file diff --git a/KfChatDotNetBot/KfChatDotNetBot.csproj b/KfChatDotNetBot/KfChatDotNetBot.csproj index e22431a..0e42bc2 100644 --- a/KfChatDotNetBot/KfChatDotNetBot.csproj +++ b/KfChatDotNetBot/KfChatDotNetBot.csproj @@ -17,6 +17,10 @@ runtime; build; native; contentfiles; analyzers; buildtransitive + + all + runtime; build; native; contentfiles; analyzers; buildtransitive +