[debug-tools] Module init. (#9)

This commit is contained in:
Andriy
2022-03-17 17:39:57 +02:00
committed by GitHub
parent c1008e1040
commit 6ddea8ed1a
5 changed files with 71 additions and 2 deletions
+10
View File
@@ -0,0 +1,10 @@
using Kruzya.TelegramBot.Core;
namespace West.TelegramBot.DebugTools;
public class DebugTools : Module
{
public DebugTools(Core core) : base(core)
{
}
}
+18
View File
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AssemblyName>TelegramBot.DebugTools</AssemblyName>
<RootNamespace>West.TelegramBot.DebugTools</RootNamespace>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\Core\Core.csproj" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Delete Files="$(OutDir)\TelegramBot.dll" />
</Target>
</Project>
+33
View File
@@ -0,0 +1,33 @@
using BotFramework;
using BotFramework.Attributes;
using BotFramework.Enums;
using Kruzya.TelegramBot.Core.Service;
using Newtonsoft.Json;
using Telegram.Bot;
using Telegram.Bot.Types.Enums;
namespace West.TelegramBot.DebugTools;
public class Handler : BotEventHandler
{
private readonly UserService _userService;
public Handler(UserService userService)
{
_userService = userService;
}
[Command(InChat.All, "dump", CommandParseMode.Both)]
public async Task HandleDump()
{
if (!_userService.IsUserSuper(From))
{
return;
}
var message = RawUpdate.Message!;
await Bot.SendTextMessageAsync(Chat.Id,
$"<code>{JsonConvert.SerializeObject(message.ReplyToMessage, Formatting.Indented)}</code>",
replyToMessageId: message.MessageId, parseMode: ParseMode.Html);
}
}