feat: created auth hook on TClient
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using JOBot.TClient.Infrastructure.Extensions;
|
||||
using Telegram.Bot;
|
||||
using Telegram.Bot.Types;
|
||||
|
||||
@@ -11,7 +12,7 @@ public class FallbackException : Exception
|
||||
{
|
||||
public FallbackException(string message, Message botMessage, ITelegramBotClient botClient) : base(message)
|
||||
{
|
||||
botClient.SendMessage(botMessage.Chat.Id,
|
||||
botClient.SendMessageRemK(botMessage.Chat.Id,
|
||||
TextResource.FallbackMessage);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using Telegram.Bot;
|
||||
using Telegram.Bot.Types;
|
||||
using Telegram.Bot.Types.Enums;
|
||||
using Telegram.Bot.Types.ReplyMarkups;
|
||||
|
||||
namespace JOBot.TClient.Infrastructure.Extensions;
|
||||
|
||||
public static class TelegramBotClientExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension method for auto-remove of reply keyboard if is null
|
||||
/// </summary>
|
||||
/// <param name="bot"></param>
|
||||
/// <param name="chatId"></param>
|
||||
/// <param name="text"></param>
|
||||
/// <param name="parseMode"></param>
|
||||
/// <param name="replyParameters"></param>
|
||||
/// <param name="replyMarkup"></param>
|
||||
/// <param name="linkPreviewOptions"></param>
|
||||
/// <param name="messageThreadId"></param>
|
||||
/// <param name="entities"></param>
|
||||
/// <param name="disableNotification"></param>
|
||||
/// <param name="protectContent"></param>
|
||||
/// <param name="messageEffectId"></param>
|
||||
/// <param name="businessConnectionId"></param>
|
||||
/// <param name="allowPaidBroadcast"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static Task<Message> SendMessageRemK(
|
||||
this ITelegramBotClient bot,
|
||||
ChatId chatId,
|
||||
string text,
|
||||
ParseMode parseMode = default,
|
||||
ReplyParameters? replyParameters = null,
|
||||
ReplyMarkup? replyMarkup = null,
|
||||
LinkPreviewOptions? linkPreviewOptions = null,
|
||||
int? messageThreadId = null,
|
||||
IEnumerable<MessageEntity>? entities = null,
|
||||
bool disableNotification = false,
|
||||
bool protectContent = false,
|
||||
string? messageEffectId = null,
|
||||
string? businessConnectionId = null,
|
||||
bool allowPaidBroadcast = false,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
replyMarkup ??= new ReplyKeyboardRemove();
|
||||
|
||||
return bot.SendMessage(chatId, text, parseMode, replyParameters, replyMarkup, linkPreviewOptions, messageThreadId,
|
||||
entities, disableNotification, protectContent, messageEffectId, businessConnectionId, allowPaidBroadcast,
|
||||
cancellationToken);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user