-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
47 lines (41 loc) · 1.43 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 Telegram.Bot;
using Telegram.Bot.Polling;
using Telegram.Bot.Types;
using Telegram.Bot.Types.Enums;
namespace Telegram
{
internal class Program
{
static TelegramBotClient Bot = new TelegramBotClient("YOUR_API_KEY_HERE!");
static void Main(string[] args)
{
var receiverOptions = new ReceiverOptions
{
AllowedUpdates = new UpdateType[]
{
UpdateType.Message,
UpdateType.EditedMessage,
}
};
Bot.StartReceiving(updateHandler, ErrorHandler, receiverOptions);
Console.ReadLine();
}
private static Task ErrorHandler(ITelegramBotClient arg1, Exception arg2, CancellationToken arg3)
{
throw new NotImplementedException();
}
private static async Task updateHandler(ITelegramBotClient bot, Update update, CancellationToken arg3)
{
if(update.Type == UpdateType.Message)
{
if(update.Message.Type == MessageType.Text)
{
var text = update.Message.Text;
var id = update.Message.Chat.Id;
string? username = update.Message.Chat.Username;
Console.WriteLine($"{username} | {id} | {text}");
}
}
}
}
}