Telegram.BotKit
1.3.0
dotnet add package Telegram.BotKit --version 1.3.0
NuGet\Install-Package Telegram.BotKit -Version 1.3.0
<PackageReference Include="Telegram.BotKit" Version="1.3.0" />
<PackageVersion Include="Telegram.BotKit" Version="1.3.0" />
<PackageReference Include="Telegram.BotKit" />
paket add Telegram.BotKit --version 1.3.0
#r "nuget: Telegram.BotKit, 1.3.0"
#:package Telegram.BotKit@1.3.0
#addin nuget:?package=Telegram.BotKit&version=1.3.0
#tool nuget:?package=Telegram.BotKit&version=1.3.0
Telegram.BotKit 🤖
A structured, extensible .NET Framework for building Telegram bots.
Built on top of the popular Telegram.Bot library, adopting ASP.NET Core principles: strong typing, Dependency Injection, and a Middleware Pipeline.
💡 Motivation
This project was born out of a desire to eliminate boilerplate code. Starting a new bot often meant copying the same logic over and over: string parsing, command switch-cases, and webhook configuration.
Telegram.BotKit handles this "grunt work," providing a convenient pipeline, DI, and strongly-typed parameters, allowing you to focus purely on business logic.
🏗 Architecture
The framework follows a Handler-based approach. Message processing flows through a configurable pipeline:
graph TD
Update[Telegram Update] --> Handler{Update Handler}
%% Command Flow
Handler -- "Message starts with / (default)" --> CmdDisp[Command Dispatcher]
CmdDisp --> CmdPipe[Pipeline: ErrorHandler -> User Middlewares]
CmdPipe --> CmdRouter[Router]
CmdRouter -- Reflection & Binder --> CmdInvoker[Invoker]
CmdInvoker --> CmdHandler[ICommandHandler]
%% Callback Flow
Handler -- Callback Query --> CbkDisp[Callback Dispatcher]
CbkDisp --> CbkPipe[Pipeline: ErrorHandler -> User Middlewares]
CbkPipe --> CbkRouter[Router]
CbkRouter -- JSON/Url Binder --> CbkInvoker[Invoker]
CbkInvoker --> CbkHandler[ICallbackHandler]
✨ Features
- Smart Binding: Automatically maps text like
/duel rps 5into a typed objectclass { Game="rps", Wins=5 }. Supports quotes (key="val") and named arguments. - Hybrid Hosting: Supports both Long Polling (Console) and Webhooks (ASP.NET Core) out of the box — switch modes with a single line in the config.
- Middleware: Global error handling, logging, and custom logic layers.
- Clear Structure: Clean separation of logic for Commands and Inline Callbacks.
📦 Installation & Example
A complete usage example with source code can be found in the 📂 Telegram.BotKit.Example directory.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- Telegram.Bot (>= 22.9.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.