-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEcho.cs
29 lines (25 loc) · 838 Bytes
/
Echo.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
using System;
using System.Threading.Tasks;
using RxTelegram.Bot.Interface.BaseTypes.Requests.Messages;
namespace RxTelegram.Bot.Examples.Echo;
public static class Echo
{
private const string BotToken = "<PASTE YOUR BOT TOKEN HERE>";
public static async Task Main()
{
var bot = new TelegramBot($"{BotToken}");
var me = await bot.GetMe();
Console.WriteLine($"Bot name: @{me.Username}");
var subscription = bot.Updates.Message.Subscribe(x =>
{
bot.SendMessage(new SendMessage
{
ChatId = x.Chat.Id,
Text = x.Text
});
},
exception => Console.WriteLine($"An error has occured: {exception.Message}"));
Console.ReadLine();
subscription.Dispose();
}
}