Skip to content

yakcom/Telegram.Bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Telegram.Bot

Library shell TgNet for easy creation of group chat bots Telegram


Typing SVG

Using

using Telegram.Bot;

Quick Start

using Telegram.Bot;

void Main()
{
    TgBot = new TelegramBot();
    TgBot.Authorization("YOUR_TG_GROUP_API_TOKEN");
    TgBot.Start(Handle);
}

void Handle(long id, string text)
{
    TgBot.Send(id, "Hello World");
}

Console Example

using Telegram.Bot;

namespace Example
{
    internal class Simple
    {
        static TelegramBot TgBot;
        static void Main(string[] args)
        {
            TgBot = new TelegramBot();
            TgBot.Authorization("YOUR_TG_GROUP_API_TOKEN");
            TgBot.Start(Handle);
            Console.Read();
        }

        static void Handle(long id,string text)
        {
            TgBot.Send(id, $"Hello Id: {id}\nYou Say: {text}");
            TgBot.Send(id, "Test Inline Keyboard", "Button11;Button21,Button22;Button31,Button32,Button33", true);
            TgBot.Send(id, "Test Outline Keyboard", "Contact|CONTACT;Location|LOCATION;Poll|POLL");
        }
    }
}




Keyboard general

Keyboard generated from string with 3 main separators:

Symbol [ ; ] separates the vertical lines of the buttons

Symbol [ , ] separates buttons on a line

Symbol [ | ] separates the text of the button and its options

Example regular keyboard

TgBot.Send(id, "Example Test", "Button1Line1;Button1Line2,Button2Line2;Button1Line3,Button2Line3,Button3Line3");




Keyboard button options

Expression Button
CONTACT Share Contact
LOCATION Share Location
POLL Create Poll
URL Create Url

Example keyboard with button options

TgBot.Send(id, "Test", "Share Contact|CONTACT;Share Location|LOCATION;Create Poll|POLL");




Additional functions arguments

Send function has 2 additional arguments

Inline - keyboard embedded in message

OneTime - keyboard hides on next message

Large - big keyboard buttons

Example inline keyboard

TgBot.Send(id, "Example Test", "Button1Line1;Button1Line2,Button2Line2;Button1Line3,Button2Line3,Button3Line3",true);




Changing keyboard split characters

Function SetKeyboardSplitters() allows you to specify your own characters as separators

Example

TgBot.SetKeyboardSplitters(':', '.', '|');
TgBot.Send(id, "Test keyboard", "Button1|CONTACT.Button2|LOCATION:Button3|POLL");

About

Library shell TgNet for easy creation of chat bots Telegram

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages