Created
August 11, 2018 17:22
-
-
Save MihaZupan/c5076b06c5b73cbc3b0f71cc6e6b4709 to your computer and use it in GitHub Desktop.
Sample Telegram bot for Telegram.Bot wiki (https://github.com/TelegramBots/Telegram.Bot/wiki)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Telegram.Bot; | |
using Telegram.Bot.Args; | |
using Telegram.Bot.Types; | |
using Telegram.Bot.Types.Enums; | |
namespace HelloBot | |
{ | |
class Program | |
{ | |
static readonly TelegramBotClient Bot = new TelegramBotClient("API Token"); | |
static void Main(string[] args) | |
{ | |
Bot.OnMessage += Bot_OnMessage; | |
Bot.StartReceiving(); | |
while (true) Console.ReadKey(true); | |
} | |
private static async void Bot_OnMessage(object sender, MessageEventArgs e) | |
{ | |
Message message = e.Message; | |
if (message.Type == MessageType.Text) | |
{ | |
await Bot.SendTextMessageAsync(message.Chat, "Hello"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment