Skip to content

Instantly share code, notes, and snippets.

@MihaZupan
Created August 11, 2018 17:22
Show Gist options
  • Save MihaZupan/c5076b06c5b73cbc3b0f71cc6e6b4709 to your computer and use it in GitHub Desktop.
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)
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