Add faq to add subscription
This commit is contained in:
parent
fbd1ee5f0f
commit
cf167e75c9
@ -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<AddSubscriptionMatcher>
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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<NocrState>
|
||||||
|
{
|
||||||
|
public AddSubscriptionMatcher()
|
||||||
|
{
|
||||||
|
ExpectingState = NocrState.AddSubscription;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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<NocrState>
|
|
||||||
{
|
|
||||||
public AddSubscriptionMatcher()
|
|
||||||
{
|
|
||||||
ExpectingState = NocrState.AddSubscription;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class AddSubscriptionHandler : IMatchingUpdateHandler<AddSubscriptionMatcher>
|
|
||||||
{
|
|
||||||
private readonly ILogger<AddSubscriptionHandler> _logger;
|
|
||||||
private readonly ILocalizer _localizer;
|
|
||||||
private readonly IBot _bot;
|
|
||||||
|
|
||||||
public AddSubscriptionHandler(ILogger<AddSubscriptionHandler> 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -19,6 +19,6 @@
|
|||||||
"BasePath": "http://localhost:5001"
|
"BasePath": "http://localhost:5001"
|
||||||
},
|
},
|
||||||
"AdministrationOptions": {
|
"AdministrationOptions": {
|
||||||
"EnableUpdateTelegramLogging": true
|
"EnableUpdateTelegramLogging": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user