forked from codEnjoyer/Dictionchy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
39 lines (35 loc) · 1.22 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using Telegram.Bot;
using Telegram.Bot.Types;
using Telegram.Bot.Polling;
using Dictionchy.Handlers;
namespace Dictionchy
{
public static class Program
{
private static readonly ITelegramBotClient Bot = new TelegramBotClient(DotEnv.Token);
private static async Task HandleUpdateAsync(ITelegramBotClient botClient, Update update,
CancellationToken cancellationToken)
{
await UpdateHandler.HandleUpdateAsync(botClient, update, cancellationToken);
}
private static async Task HandleErrorAsync(ITelegramBotClient botClient, Exception exception,
CancellationToken cancellationToken)
{
await ErrorHandler.HandleErrorAsync(botClient, exception, cancellationToken);
}
private static void Main()
{
DotEnv.Load(EnvFileType.Json);
var cts = new CancellationTokenSource();
var cancellationToken = cts.Token;
var receiverOptions = new ReceiverOptions();
Bot.StartReceiving(
HandleUpdateAsync,
HandleErrorAsync,
receiverOptions,
cancellationToken
);
Console.ReadLine();
}
}
}