-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathProgram.cs
47 lines (37 loc) · 1.21 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
40
41
42
43
44
45
46
47
using System.Timers;
using AsyncFormUpdates.Forms;
using TelegramBotBase;
using TelegramBotBase.Builder;
using Timer = System.Timers.Timer;
namespace AsyncFormUpdates;
internal class Program
{
private static BotBase __bot;
private static async Task Main(string[] args)
{
__bot = BotBaseBuilder.Create()
.QuickStart<Start>(Environment.GetEnvironmentVariable("API_KEY") ??
throw new Exception("API_KEY is not set"))
.Build();
await __bot.Start();
var timer = new Timer(5000);
timer.Elapsed += Timer_Elapsed;
timer.Start();
Console.ReadLine();
timer.Stop();
await __bot.Stop();
}
private static async void Timer_Elapsed(object sender, ElapsedEventArgs e)
{
foreach (var s in __bot.Sessions.SessionList)
{
//Only for AsyncUpdateForm
if (s.Value.ActiveForm.GetType() != typeof(AsyncFormUpdate) &&
s.Value.ActiveForm.GetType() != typeof(AsyncFormEdit))
{
continue;
}
await __bot.InvokeMessageLoop(s.Key);
}
}
}