chore: init commit from GitHub
Some checks are pending
Deploy / update (push) Waiting to run
Build Project .NET / build (push) Waiting to run

This commit is contained in:
Lisoveliy
2025-05-12 19:44:33 +03:00
parent 11a3f40596
commit aebe654c38
107 changed files with 18953 additions and 403 deletions

61
TelegramBot/BotHandler.cs Normal file
View File

@@ -0,0 +1,61 @@
using Telegram.Bot;
using Telegram.Bot.Types;
using Telegram.Bot.Types.Enums;
using TelegramBot.Commands;
using TelegramBot.Commands.CommandMessages;
namespace TelegramBot;
public static class BotHandler
{
private static readonly LinkMessage LinkMessageProvider = new();
private static readonly StartCommandMessage StartCommandMessageProvider = new();
private static readonly ChangelogCommandMessage ChangelogCommandMessageProvider = new();
private static readonly ErrorMessage ErrorMessageProvider = new();
public static async Task HandleUpdateAsync(
ITelegramBotClient botClient,
Update update,
CancellationToken cancellationToken
)
{
switch (update.Type)
{
case UpdateType.Message:
switch (update.Message?.Text)
{
case StartCommandMessage.CommandName:
await StartCommandMessageProvider.InvokeFromMessage(botClient, update, cancellationToken);
break;
case ChangelogCommandMessage.CommandName:
await ChangelogCommandMessageProvider.InvokeFromMessage(botClient, update, cancellationToken);
break;
default:
Console.WriteLine(update.Message?.Text);
if (string.IsNullOrEmpty(update.Message?.Text))
{
await ErrorMessageProvider.InvokeFromMessage(botClient, update, cancellationToken);
break;
}
await LinkMessageProvider.InvokeFromMessage(botClient, update, cancellationToken);
break;
}
break;
case UpdateType.InlineQuery:
await LinkMessageProvider.InvokeFromInlineQuery(botClient, update, cancellationToken);
break;
}
}
public static Task HandleErrorAsync(
ITelegramBotClient botClient,
Exception exception,
CancellationToken cancellationToken
)
{
Console.WriteLine("Ошибка ядра:\n--------------------------");
Console.WriteLine(exception);
return Task.CompletedTask;
// throw exception;
}
}