TeleBotFramework 1.3.4
dotnet add package TeleBotFramework --version 1.3.4
NuGet\Install-Package TeleBotFramework -Version 1.3.4
<PackageReference Include="TeleBotFramework" Version="1.3.4" />
<PackageVersion Include="TeleBotFramework" Version="1.3.4" />
<PackageReference Include="TeleBotFramework" />
paket add TeleBotFramework --version 1.3.4
#r "nuget: TeleBotFramework, 1.3.4"
#:package TeleBotFramework@1.3.4
#addin nuget:?package=TeleBotFramework&version=1.3.4
#tool nuget:?package=TeleBotFramework&version=1.3.4
TeleBotFramework
Minimalistic, dependency-injection-first command framework for Telegram.Bot, designed to let you build modular, maintainable Telegram bots with almost zero boilerplate.
✨ Features
- ITelegramCommand-based commands – just implement the interface
- Auto-registration of all commands found in your assemblies
- IServiceCollection extension:
AddTelegramFramework(...)
- ITelegramUpdateHandler dispatches incoming updates to your commands
- ITeleBotClient override of default Telegram.Bot client to balance request count per second
- IUserStateManager for per-user state persistence across sessions
- MarkdownHelper utility to safely format Markdown messages
- Ready to use in ASP.NET Core (webhook) or long-polling console apps
⚙️ Installation
dotnet add package TeleBotFramework
🚀 Usage
1. Configure your bot in ASP.NET Core (webhook)
csharp
Copy
Edit
using Microsoft.AspNetCore.Mvc;
using TeleBotFramework;
using Telegram.Bot;
using Telegram.Bot.Types;
var builder = WebApplication.CreateBuilder(args);
// 1️⃣ Register your TelegramBotClient
builder.Services.AddSingleton<ITelegramBotClient>(sp =>
{
var cfg = sp.GetRequiredService<IConfiguration>();
var token = cfg["Telegram:Token"];
if (string.IsNullOrWhiteSpace(token))
throw new ArgumentException("Telegram:Token is missing");
return new TelegramBotClient(token);
});
// 2️⃣ Add MVC & the framework, scanning your command assembly
builder.Services.AddControllers();
builder.Services.AddTelegramFramework(typeof(StartCommand).Assembly);
var app = builder.Build();
// 3️⃣ Map the webhook endpoint
app.MapPost("/bot/webhook", async (
[FromBody] Update update,
[FromServices] ITelegramUpdateHandler handler) =>
{
await handler.HandleUpdate(update);
return Results.Ok();
});
app.Run();
2. Define a command
Create a class in your project (e.g. under Commands/) that implements ITelegramCommand:
using TeleBotFramework.Commands;
using TeleBotFramework.Models;
using Telegram.Bot;
namespace TeleBotFramework.SimpleExample.Commands
[Command("/start", "Start operation", true)]
internal class StartCommand(ITeleBotClient bot) : ITelegramCommand
{
private readonly ITeleBotClient _bot = bot;
public async Task Execute(UpdateInfo update)
{
await _bot.SendMessage(update.ChatId, $"Hello, {update.Username ?? update.FirstName + " " + update.LastName}");
}
}
- Name - command name to call it
- Description - will be shown in bot menu
3. Run the example
A complete ASP.NET Core example lives under: examples/TeleBotFramework.SimpleExample/
To try it out:
git clone https://github.com/Alados/TeleBotFramework.git
cd TeleBotFramework/examples/TeleBotFramework.SimpleExample
dotnet run
Available on Nuget
Link - https://www.nuget.org/packages/TeleBotFramework/
📂 Repository structure
/TeleBotFramework/ # Core library
/Commands/ # ITelegramCommand + any built-in commands
/Handlers/ # Update dispatching & routing
/Models/ # UpdateInfo, other DTOs
/Extensions/ # IServiceCollection extensions
/Client/ # ITeleBotClient client
/State/ # IUserStateManager implementations
/Utils/ # MarkdownHelper and other helpers
/examples/
/TeleBotFramework.SimpleExample/ # ASP.NET Core webhook sample
.gitignore
README.md
LICENSE
🤝 Contributing
Contributions, issues and feature requests are welcome!
- Fork the repo
- Create your feature branch (git checkout -b feature/foo)
- Commit your changes (git commit -am "Add foo")
- Push to the branch (git push origin feature/foo)
- Open a Pull Request
📄 License
This project is licensed under the MIT License. See LICENSE for details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. |
-
net9.0
- Microsoft.Extensions.DependencyInjection (>= 9.0.6)
- Microsoft.Extensions.Hosting (>= 9.0.6)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.6)
- 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 |
---|---|---|
1.3.4 | 87 | 7/29/2025 |
1.3.3 | 86 | 7/29/2025 |
1.3.2 | 189 | 7/20/2025 |
1.3.1 | 182 | 7/20/2025 |
1.3.0 | 125 | 7/16/2025 |
1.2.2 | 134 | 7/15/2025 |
1.2.0 | 135 | 7/13/2025 |
1.1.5 | 95 | 7/11/2025 |
1.1.4 | 141 | 7/3/2025 |
1.1.3 | 127 | 7/3/2025 |
1.1.2 | 134 | 7/3/2025 |
1.1.1 | 130 | 7/3/2025 |
1.1.0 | 128 | 7/3/2025 |
1.0.15 | 139 | 6/30/2025 |
1.0.14 | 127 | 6/30/2025 |
1.0.13 | 135 | 6/29/2025 |
1.0.12 | 135 | 6/29/2025 |
1.0.11 | 137 | 6/29/2025 |
1.0.9 | 80 | 6/27/2025 |
1.0.8 | 136 | 6/25/2025 |
1.0.7 | 138 | 6/25/2025 |
1.0.6 | 101 | 6/20/2025 |
1.0.5 | 98 | 6/20/2025 |
1.0.4 | 98 | 6/20/2025 |
1.0.3 | 99 | 6/20/2025 |
1.0.2 | 101 | 6/20/2025 |
1.0.1 | 102 | 6/20/2025 |
1.0.0 | 97 | 6/20/2025 |
1.0.0-beta-1 | 99 | 6/20/2025 |