mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
31 lines
863 B
C#
31 lines
863 B
C#
|
|
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);
|
||
|
|
}
|
||
|
|
}
|