mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
[quote] Crappy chat quote implementation.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using BotFramework;
|
||||
using BotFramework.Attributes;
|
||||
using BotFramework.Enums;
|
||||
using Telegram.Bot;
|
||||
using Telegram.Bot.Types.InputFiles;
|
||||
|
||||
namespace West.TelegramBot.ChatQuotes.Handler;
|
||||
|
||||
public class Quote : BotEventHandler
|
||||
{
|
||||
private readonly QuoteGeneratorService _quoteGenerator;
|
||||
|
||||
public Quote(QuoteGeneratorService quoteGenerator)
|
||||
{
|
||||
_quoteGenerator = quoteGenerator;
|
||||
}
|
||||
|
||||
[Command(InChat.Public, "q", CommandParseMode.Both)]
|
||||
public async Task HandleQuote()
|
||||
{
|
||||
var msg = RawUpdate.Message;
|
||||
var replyToMessage = msg?.ReplyToMessage;
|
||||
if (msg == null || replyToMessage == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var file = new InputOnlineFile(await _quoteGenerator.GenerateQuoteImage(replyToMessage));
|
||||
await Bot.SendStickerAsync(Chat.Id, file, replyToMessageId: msg.MessageId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user