-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCypherBot.cs
55 lines (45 loc) · 2.03 KB
/
CypherBot.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Threading;
using Telegram.Bot;
using Telegram.Bot.Extensions.Polling;
using Telegram.Bot.Types;
namespace CypherBot
{
internal static class CypherBot
{
public static CultureInfo ci = new CultureInfo("en-US");
public static TelegramBotClient botClient = new TelegramBotClient(Props.telegramToken);
private static void Main(string[] args)
{
Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
Thread.CurrentThread.CurrentCulture = ci;
Thread.CurrentThread.CurrentUICulture = ci;
CultureInfo.DefaultThreadCurrentCulture = ci;
CultureInfo.DefaultThreadCurrentUICulture = ci;
CultureInfo.CurrentCulture = ci;
CultureInfo.CurrentUICulture = ci;
Data.ChannelPosts.LoadPostsData();
Data.SorteioParticipantes.LoadParticipantesData();
Data.MessagesToDelete.timerMessageToDeletesData.Elapsed += Data.MessagesToDelete.TimerMessageToDeletesData_Elapsed;
Data.MessagesToDelete.LoadMessageToDeletesData();
Data.MessagesToDelete.timerMessageToDeletesData.Start();
Thread.Sleep(1000);
User me = botClient.GetMeAsync().Result;
using var cts = new CancellationTokenSource();
// StartReceiving does not block the caller thread. Receiving is done on the ThreadPool.
ReceiverOptions receiverOptions = new() { AllowedUpdates = { } };
botClient.StartReceiving(TelegramHandlers.HandleUpdateAsync,
TelegramHandlers.HandleErrorAsync,
receiverOptions,
cts.Token);
Console.WriteLine($"Telegram Bot start listening for @{me.Username}");
while (true)
{
Console.Read();
}
}
}
}