diff --git a/Dockerfile b/Dockerfile index d4b4d91..a66e58a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,8 @@ COPY ./modules/Entertainment/*.csproj ./modules/Entertainment/ COPY ./modules/UserGroupTag/*.csproj ./modules/UserGroupTag/ COPY ./modules/ChatQuotes/*.csproj ./modules/ChatQuotes/ COPY ./modules/Reputation/*.csproj ./modules/Reputation/ -COPY ./modules/ContentStore/*.csproj ./modules/ContentStore/ +COPY ./modules/ContentStore/*.csproj ./modules/ContentStore/ +COPY ./modules/DebugTools/*.csproj ./modules/DebugTools/ RUN dotnet restore Kruzya.TelegramBot.sln # Copy all project files diff --git a/Kruzya.TelegramBot.sln b/Kruzya.TelegramBot.sln index a995a9a..c13f95f 100644 --- a/Kruzya.TelegramBot.sln +++ b/Kruzya.TelegramBot.sln @@ -27,7 +27,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ChatQuotes", "modules\ChatQ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Reputation", "modules\Reputation\Reputation.csproj", "{03F3C7D5-6FEF-4A83-9191-501091BFC1AC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ContentStore", "modules\ContentStore\ContentStore.csproj", "{4F1E8FE8-640F-4671-87FC-0FFCCB6EDF5E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ContentStore", "modules\ContentStore\ContentStore.csproj", "{4F1E8FE8-640F-4671-87FC-0FFCCB6EDF5E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DebugTools", "modules\DebugTools\DebugTools.csproj", "{B95C9180-4893-4A33-BF43-AB2EE998650C}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -83,6 +85,10 @@ Global {4F1E8FE8-640F-4671-87FC-0FFCCB6EDF5E}.Debug|Any CPU.Build.0 = Debug|Any CPU {4F1E8FE8-640F-4671-87FC-0FFCCB6EDF5E}.Release|Any CPU.ActiveCfg = Release|Any CPU {4F1E8FE8-640F-4671-87FC-0FFCCB6EDF5E}.Release|Any CPU.Build.0 = Release|Any CPU + {B95C9180-4893-4A33-BF43-AB2EE998650C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B95C9180-4893-4A33-BF43-AB2EE998650C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B95C9180-4893-4A33-BF43-AB2EE998650C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B95C9180-4893-4A33-BF43-AB2EE998650C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -98,6 +104,7 @@ Global {04F16325-8F44-4250-9B2E-0F77E8F65CBF} = {C7821F15-DEDD-474F-A575-A296D4B58F10} {03F3C7D5-6FEF-4A83-9191-501091BFC1AC} = {C7821F15-DEDD-474F-A575-A296D4B58F10} {4F1E8FE8-640F-4671-87FC-0FFCCB6EDF5E} = {C7821F15-DEDD-474F-A575-A296D4B58F10} + {B95C9180-4893-4A33-BF43-AB2EE998650C} = {C7821F15-DEDD-474F-A575-A296D4B58F10} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {5BA73C3B-D5FC-4942-9091-504325CDC308} diff --git a/modules/DebugTools/DebugTools.cs b/modules/DebugTools/DebugTools.cs new file mode 100644 index 0000000..fc80f52 --- /dev/null +++ b/modules/DebugTools/DebugTools.cs @@ -0,0 +1,10 @@ +using Kruzya.TelegramBot.Core; + +namespace West.TelegramBot.DebugTools; + +public class DebugTools : Module +{ + public DebugTools(Core core) : base(core) + { + } +} \ No newline at end of file diff --git a/modules/DebugTools/DebugTools.csproj b/modules/DebugTools/DebugTools.csproj new file mode 100644 index 0000000..763cd93 --- /dev/null +++ b/modules/DebugTools/DebugTools.csproj @@ -0,0 +1,18 @@ + + + + net6.0 + enable + enable + TelegramBot.DebugTools + West.TelegramBot.DebugTools + + + + + + + + + + diff --git a/modules/DebugTools/Handler.cs b/modules/DebugTools/Handler.cs new file mode 100644 index 0000000..e7a73bb --- /dev/null +++ b/modules/DebugTools/Handler.cs @@ -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, + $"{JsonConvert.SerializeObject(message.ReplyToMessage, Formatting.Indented)}", + replyToMessageId: message.MessageId, parseMode: ParseMode.Html); + } +} \ No newline at end of file