diff --git a/src/Nocr.TelegramClient.AppServices/Handlers/CallbackQueries/AddSubscription/AddSubscriptionHandler.cs b/src/Nocr.TelegramClient.AppServices/Handlers/CallbackQueries/AddSubscription/AddSubscriptionHandler.cs new file mode 100644 index 0000000..86e44eb --- /dev/null +++ b/src/Nocr.TelegramClient.AppServices/Handlers/CallbackQueries/AddSubscription/AddSubscriptionHandler.cs @@ -0,0 +1,37 @@ +using Insight.Localizer; +using Insight.TelegramBot; +using Insight.TelegramBot.Handling.Handlers; +using Insight.TelegramBot.Models; +using Nocr.TelegramClient.AppServices.Bots; +using Telegram.Bot.Types; +using Telegram.Bot.Types.ReplyMarkups; + +namespace Nocr.TelegramClient.AppServices.Handlers.CallbackQueries.AddSubscription; + +public sealed class AddSubscriptionHandler : IMatchingUpdateHandler +{ + private readonly ILocalizer _localizer; + private readonly IBot _bot; + + private const string FaqFileId = "CgACAgIAAxkBAAIPQmY5H7c3pi5_4OxdPbpRVdnwEFMxAAIBTAACnxzJSefFRShccLRXNQQ"; + + public AddSubscriptionHandler(ILocalizer localizer, IBot bot) + { + _localizer = localizer ?? throw new ArgumentNullException(nameof(localizer)); + _bot = bot ?? throw new ArgumentNullException(nameof(bot)); + } + + public Task Handle(Update update, CancellationToken cancellationToken = default) + { + var message = new AnimationMessage(update.CallbackQuery.Message.Chat.Id) + { + InputOnlineFile = new InputFileId(FaqFileId), + Caption = _localizer.Get(nameof(AddSubscriptionHandler), "Text"), + ReplyMarkup = new InlineKeyboardMarkup(new InlineKeyboardButton(_localizer.Get("buttons", "back")) + { + CallbackData = NocrCallbackData.Start().ToString() + }) + }; + return _bot.SendAnimationAsync(message, cancellationToken); + } +} \ No newline at end of file diff --git a/src/Nocr.TelegramClient.AppServices/Handlers/CallbackQueries/AddSubscription/AddSubscriptionMatcher.cs b/src/Nocr.TelegramClient.AppServices/Handlers/CallbackQueries/AddSubscription/AddSubscriptionMatcher.cs new file mode 100644 index 0000000..34a6030 --- /dev/null +++ b/src/Nocr.TelegramClient.AppServices/Handlers/CallbackQueries/AddSubscription/AddSubscriptionMatcher.cs @@ -0,0 +1,12 @@ +using Insight.TelegramBot.Handling.Matchers.CallbackQueryMatchers; +using Nocr.TelegramClient.AppServices.Bots; + +namespace Nocr.TelegramClient.AppServices.Handlers.CallbackQueries.AddSubscription; + +public class AddSubscriptionMatcher : StateCallbackQueryMatcher +{ + public AddSubscriptionMatcher() + { + ExpectingState = NocrState.AddSubscription; + } +} \ No newline at end of file diff --git a/src/Nocr.TelegramClient.AppServices/Handlers/CallbackQueries/AddSubscription/FeedbackHandler.cs b/src/Nocr.TelegramClient.AppServices/Handlers/CallbackQueries/AddSubscription/FeedbackHandler.cs deleted file mode 100644 index 4a8671a..0000000 --- a/src/Nocr.TelegramClient.AppServices/Handlers/CallbackQueries/AddSubscription/FeedbackHandler.cs +++ /dev/null @@ -1,47 +0,0 @@ -using Insight.Localizer; -using Insight.TelegramBot; -using Insight.TelegramBot.Handling.Handlers; -using Insight.TelegramBot.Handling.Matchers.CallbackQueryMatchers; -using Insight.TelegramBot.Models; -using Microsoft.Extensions.Logging; -using Nocr.TelegramClient.AppServices.Bots; -using Telegram.Bot.Types; -using Telegram.Bot.Types.ReplyMarkups; - -namespace Nocr.TelegramClient.AppServices.Handlers.CallbackQueries.Feedback; - -public class AddSubscriptionMatcher : StateCallbackQueryMatcher -{ - public AddSubscriptionMatcher() - { - ExpectingState = NocrState.AddSubscription; - } -} - -public class AddSubscriptionHandler : IMatchingUpdateHandler -{ - private readonly ILogger _logger; - private readonly ILocalizer _localizer; - private readonly IBot _bot; - - public AddSubscriptionHandler(ILogger logger, ILocalizer localizer, IBot bot) - { - _logger = logger ?? throw new ArgumentNullException(nameof(logger)); - _localizer = localizer ?? throw new ArgumentNullException(nameof(localizer)); - _bot = bot ?? throw new ArgumentNullException(nameof(bot)); - } - - public Task Handle(Update update, CancellationToken cancellationToken = default) - { - var message = new TextMessage(update.CallbackQuery.Message.Chat.Id) - { - Text = _localizer.Get(nameof(AddSubscriptionHandler), "Text"), - ReplyMarkup = new InlineKeyboardMarkup(new InlineKeyboardButton(_localizer.Get("buttons", "back")) - { - CallbackData = NocrCallbackData.Start().ToString() - }) - }; - - return _bot.EditOrSendTextMessage(update.CallbackQuery.Message.MessageId, message, _logger, cancellationToken); - } -} \ No newline at end of file diff --git a/src/Nocr.TelegramClient.Host/appsettings.Development.json b/src/Nocr.TelegramClient.Host/appsettings.Development.json index a9946fd..ef1d616 100644 --- a/src/Nocr.TelegramClient.Host/appsettings.Development.json +++ b/src/Nocr.TelegramClient.Host/appsettings.Development.json @@ -19,6 +19,6 @@ "BasePath": "http://localhost:5001" }, "AdministrationOptions": { - "EnableUpdateTelegramLogging": true + "EnableUpdateTelegramLogging": false } }