Tebot 0.2.54
See the version list below for details.
dotnet add package Tebot --version 0.2.54
NuGet\Install-Package Tebot -Version 0.2.54
<PackageReference Include="Tebot" Version="0.2.54" />
<PackageVersion Include="Tebot" Version="0.2.54" />
<PackageReference Include="Tebot" />
paket add Tebot --version 0.2.54
#r "nuget: Tebot, 0.2.54"
#:package Tebot@0.2.54
#addin nuget:?package=Tebot&version=0.2.54
#tool nuget:?package=Tebot&version=0.2.54
Tebot
This is a small wrapper library for Telegram.Bot. With it, you can simplify the creation of complex bot logic. In TebotConsole you can find a example small console app.
Why?
When you try to make telegram bot on Telegram.Bot, you usually have one big method like OnUpdate(Update update, ...) which process every update. And in this method you usually have a lot of if/else, switch and other shit. With this, you method easy can grow up to many lines of code.\n\n
But with this libary we can represent user as class instance, and all updates and actions from concrete user will be applyed only to class instance
Base usage
For first, you should create you own class, which derivites from Tebot.Base, for example
public class Bot : Base{
}
All class have a thing which we call "State". So, with this we can have class as State machine. Lets create class with 2 states:
public class StateMachine : Base{
[StateId(State = "/start")]
public async Task HelloWorld(){
await Bot.SendTextMessageAsync(UserId, "Hello world");
NextState = "Bye";
}
[StateId(State = "Bye")]
public async Task ByeWorld(){
await Bot.SendTextMessageAsync(UserId, "Bye world");
NextState = "/start";
}
}
So, what happens here? To get a better representation, we can to look on graph:\n
graph TD;
HelloWorld-->ByeWorld;
ByeWorld-->HelloWorld;
In general, when we send message to bot, he execute surrent state. Surrent state defined by NextState variable. To make a new state, we should create new method and add StateId attribute to him.\n\n
And, in general, it`s looks like
- User send message to bot in telegram app
- Invokes
HelloWorld()method.(because default value forNextStatevariable is a/start, but of course we can override this) - Call
await Bot.SendTextMessageAsync(UserId, "Hello world");, which send to userHello worldstring.UserIdin this context is alongvariable, defined inBaseclass and represent actual user account id. NextState = "Bye";- we setByeas next state. After this, method ends.- Now user can send another message to bot.
- After we recive new message,
TebotinvokeByeWorldmethod, because his haveStateIdattribute withByevalue. - We again send message to user
- We set next state to
/startetc we return to step 1.
And now we need only to add main method:
static void Main(string[] args)
{
var tb = new Tebot.Tebot("6510000000:AAGCKkSY***", typeof(StateMachine), StateLoader.Empty());
tb.Run();
Console.ReadKey();
tb.Stop();
}
Where first argument is bot token, second - Type to our class, and third - don`t thing about it now.
Going deeper
Dependency Injection
Library support dependency injection. To this, pass IServiceProvider in Tebot constructor. If not set, class will try to create objects by himself, pass to his constructors null value.
Host
It`s recommend to use Microsoft.Extensions.Hosting to create application. Example you can find
Commands
Telegram Bots have commands concept, and this library support it. Commands is very simular to states:
[Command("/value")]
public async Task Bebrachka(int abb = 150){
await Bot.SendTextMessageAsync(UserId, $"value x{abb}");
}
Command methods can have parameters, which will be set from command. For example, if we send to bot /value 200, then abb value will be a 200. If we send only /value, abb will be equal to default value. Now lib can parce only System.Int32, System.Int64, System.Double and System.String.
Override methods
Base class have some methods, which we can override in our class.
| Method | Method Description |
| ----------- | ----------- |
| OnLoad() | Event, when class instance was loaded |
| OnInlineQuery() | When update represents InlineQuery |
| OnCallback() | When user click on inline button with callback |
| OnCreate() | Call once after create this Base instanse by library. |
| OnCommand() | Call if user input is command(starts from / |
| OnUpdate() | Call after each update with this user |
| ProccessUnknownState() | Called when NextState value can`t be matched with state |
| OnException() | If in state we have unhandled exception, library call this method |
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Extensions.Hosting (>= 9.0.4)
- Telegram.Bot (>= 22.5.1)
-
net8.0
- Microsoft.Extensions.Hosting (>= 9.0.4)
- Telegram.Bot (>= 22.5.1)
-
net9.0
- Microsoft.Extensions.Hosting (>= 9.0.4)
- Telegram.Bot (>= 22.5.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.3.77-beta | 93 | 4/9/2026 |
| 0.3.76-beta | 97 | 4/9/2026 |
| 0.3.75-beta | 104 | 4/9/2026 |
| 0.3.74-beta | 96 | 3/9/2026 |
| 0.3.73-beta | 101 | 3/9/2026 |
| 0.3.72-beta | 107 | 3/9/2026 |
| 0.3.71-beta | 94 | 3/8/2026 |
| 0.3.70-beta | 107 | 3/8/2026 |
| 0.3.69-beta | 101 | 3/7/2026 |
| 0.2.65 | 587 | 2/26/2026 |
| 0.2.64 | 571 | 2/26/2026 |
| 0.2.63 | 574 | 2/26/2026 |
| 0.2.62 | 682 | 1/3/2026 |
| 0.2.61 | 637 | 1/3/2026 |
| 0.2.60 | 637 | 1/3/2026 |
| 0.2.58 | 641 | 1/3/2026 |
| 0.2.57 | 640 | 1/3/2026 |
| 0.2.56 | 639 | 12/31/2025 |
| 0.2.55 | 932 | 11/21/2025 |
| 0.2.54 | 898 | 11/21/2025 |