feat(debug-tools): syntax highlighting, ability to call without reply

This commit is contained in:
Andriy
2023-11-13 00:21:15 +02:00
parent f991998ec4
commit da063464f2
+5 -6
View File
@@ -1,11 +1,10 @@
using BotFramework;
using BotFramework.Attributes;
using BotFramework.Enums;
using BotFramework.Utils;
using Kruzya.TelegramBot.Core.Extensions;
using Kruzya.TelegramBot.Core.Service;
using Newtonsoft.Json;
using Telegram.Bot;
using Telegram.Bot.Types.Enums;
namespace West.TelegramBot.DebugTools;
@@ -25,10 +24,10 @@ public class Handler : BotEventHandler
{
return;
}
var message = RawUpdate.Message!.ReplyToMessage ?? RawUpdate.Message;
var text = HtmlString.Empty
.CodeWithStyle("language-json", JsonConvert.SerializeObject(message, Formatting.Indented));
var message = RawUpdate.Message!;
await Bot.SendTextMessageAsync(Chat.Id,
$"<code>{JsonConvert.SerializeObject(message.ReplyToMessage, Formatting.Indented)}</code>",
replyToMessageId: message.MessageId, parseMode: ParseMode.Html);
await Bot.SendHtmlStringAsync(Chat, text, replyTo: message.MessageId);
}
}