Skip to content
This repository was archived by the owner on Dec 20, 2022. It is now read-only.
Denis edited this page Aug 18, 2021 · 6 revisions

Welcome to the TeleBotCSharp wiki!

Quick start

Template

Importing necessary

using TeleBotCSharp;

Creating bot object in head of class

public static TeleBotCs bot;

Initializing bot object

string token = "YOUR TOKEN HERE";
bot = new TeleBotCs(token);

For handling messages adding this

var botService = new TeleBotService(bot);
botService.StartBotAsync();

Adding handler for /start

[CommandHandler("start")]
public async void Start(Result result)
{
    await bot.SendMessage(result.message.chat.id, "Hello World!");
}

Summary

namespace TelegramTestBot
{
    class Program
    {
        public static TeleBotCs bot;
        
        static void Main(string[] args)
        {
            string token = "YOUR TOKEN HERE";
            bot = new TeleBotCs(token);
            var botService = new TeleBotService(bot);
            botService.StartBotAsync();
            
        }
        
        [CommandHandler("start")]
        public async void Start(Result result)
        {
            await bot.SendMessage(result.message.chat.id, "Hello World!";
        }
    }
}
Clone this wiki locally