2022-01-21 00:10:27 +02:00
|
|
|
using BotFramework;
|
|
|
|
|
using BotFramework.Attributes;
|
|
|
|
|
using BotFramework.Enums;
|
|
|
|
|
using Telegram.Bot;
|
2023-01-02 19:01:03 +02:00
|
|
|
using Telegram.Bot.Types;
|
2022-01-21 00:10:27 +02:00
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-21 14:28:33 +02:00
|
|
|
var quoteImage = await _quoteGenerator.GenerateQuoteImage(replyToMessage);
|
|
|
|
|
if (quoteImage == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-02 19:01:03 +02:00
|
|
|
await Bot.SendStickerAsync(Chat.Id, new InputFile(quoteImage),
|
2022-01-21 14:28:33 +02:00
|
|
|
replyToMessageId: msg.MessageId);
|
2022-01-21 00:10:27 +02:00
|
|
|
}
|
|
|
|
|
}
|