Add build revision information to help message

This commit is contained in:
Laura Hausmann 2023-01-08 23:32:46 +01:00
parent ee8e685cda
commit ae909995f7
Signed by: zotan
GPG key ID: D044E84C5BE01605
2 changed files with 12 additions and 3 deletions

View file

@ -1,8 +1,11 @@
using Telegram.Bot;
using System.Reflection;
using Telegram.Bot;
using Telegram.Bot.Types;
using Telegram.Bot.Types.Enums;
var token = Environment.GetEnvironmentVariable("TELEGRAM_BOT_TOKEN")!;
var version = ((AssemblyInformationalVersionAttribute)Assembly.GetEntryAssembly()!.GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false)[0])
.InformationalVersion[6..];
using var cts = new CancellationTokenSource();
@ -118,7 +121,7 @@ async Task BotOnMessageReceived(ITelegramBotClient botClient, Message message) {
break;
case "help":
case "start":
await botClient.SendTextMessageAsync(message.Chat.Id, """
await botClient.SendTextMessageAsync(message.Chat.Id, $"""
Heya, I am a bot that can help you make decisions! Here's a list of things I can do:
/coinflip - flips a coin
@ -139,7 +142,7 @@ async Task BotOnMessageReceived(ITelegramBotClient botClient, Message message) {
Enjoy!
- Powered by [~zotan](https://zotan.pw)'s [Telegram.Bot.DecisionMaker](https://git.ztn.sh/zotan/Telegram.Bot.DecisionMaker) v1.0
I'm powered by [~zotan](https://zotan.pw)'s [Telegram.Bot.DecisionMaker](https://git.ztn.sh/zotan/Telegram.Bot.DecisionMaker) rev. [{version}](https://git.ztn.sh/zotan/Telegram.Bot.DecisionMaker/commit/{version.Replace("-dirty", "")})
""", replyToMessageId: message.MessageId, parseMode: ParseMode.Markdown, disableWebPagePreview: true);
break;
default:

View file

@ -11,4 +11,10 @@
<PackageReference Include="Telegram.Bot" Version="18.0.0" />
</ItemGroup>
<Target Name="SetSourceRevisionId" BeforeTargets="InitializeSourceControlInformation">
<Exec Command="git describe --long --always --dirty --exclude=* --abbrev=8" ConsoleToMSBuild="True" IgnoreExitCode="False">
<Output PropertyName="SourceRevisionId" TaskParameter="ConsoleOutput"/>
</Exec>
</Target>
</Project>