TelegramBotKit 0.3.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package TelegramBotKit --version 0.3.0
NuGet\Install-Package TelegramBotKit -Version 0.3.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TelegramBotKit" Version="0.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TelegramBotKit" Version="0.3.0" />
<PackageReference Include="TelegramBotKit" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TelegramBotKit --version 0.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: TelegramBotKit, 0.3.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TelegramBotKit@0.3.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TelegramBotKit&version=0.3.0
#tool nuget:?package=TelegramBotKit&version=0.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
TelegramBotKit
TelegramBotKit is a lightweight toolkit for building Telegram bots on .NET with a structured update pipeline, typed handlers, and simple command routing.
Packages
TelegramBotKit— core pipeline, commands, messaging.TelegramBotKit.Hosting— polling/hosting integration.TelegramBotKit.Routing— optional ASP.NET-styleUse*routing sugar.TelegramBotKit.Generators— optional Roslyn source generator for compile-timeAddCommands()registration.
Features
- Middleware pipeline for update processing.
- Typed update payload handlers (
IUpdatePayloadHandler<TPayload>). - Message/text/callback commands with attributes.
WaitForUserResponsehelper for request/response flows.IMessageSenderfacade for sending messages.- Optional queued sender to reduce rate-limit errors.
Installation
dotnet add package TelegramBotKit
dotnet add package TelegramBotKit.Hosting
# optional
dotnet add package TelegramBotKit.Routing
# optional (compile-time AddCommands)
dotnet add package TelegramBotKit.Generators
Quick start (polling)
- Add configuration.
Create appsettings.json:
{
"TelegramBotKit": {
"Token": "PUT_YOUR_BOT_TOKEN_HERE",
"Polling": {
"MaxDegreeOfParallelism": 4,
"Limit": 100,
"TimeoutSeconds": 10,
"AllowedUpdates": []
}
}
}
- Create a host.
using Microsoft.Extensions.Hosting;
using TelegramBotKit.DependencyInjection;
using TelegramBotKit.Hosting;
var builder = Host.CreateApplicationBuilder(args);
builder.Configuration.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
var bot = builder.Services.AddTelegramBotKit(opt =>
{
builder.Configuration.GetSection("TelegramBotKit").Bind(opt);
});
// Registers attributed commands.
// If TelegramBotKit.Generators is installed, this is compile-time.
// Otherwise it falls back to reflection-based discovery.
builder.Services.AddCommands();
bot.UseQueuedMessageSender();
builder.Services.AddTelegramBotKitPolling();
var host = builder.Build();
await host.RunAsync();
- Add a command.
using Telegram.Bot.Types;
using TelegramBotKit.Commands;
using TelegramBotKit.Messaging;
namespace MyBot.Commands;
[MessageCommand("/start")]
public sealed class StartCommand : IMessageCommand
{
public Task HandleAsync(Message message, BotContext ctx)
{
return ctx.Sender.SendText(message.Chat.Id, new SendText
{
Text = "Hello."
}, ctx.CancellationToken);
}
}
Documentation
docs/quickstart.mddocs/commands-and-routing.mddocs/middleware.mddocs/hosting.mddocs/public-api.md
Running the sample
dotnet run --project samples/TelegramBotKit.Sample.ConsolePolling
| 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.1)
- Microsoft.Extensions.Options (>= 10.0.1)
- Telegram.Bot (>= 22.8.1)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on TelegramBotKit:
| Package | Downloads |
|---|---|
|
TelegramBotKit.Hosting
Hosting and polling integration for TelegramBotKit. |
|
|
TelegramBotKit.Routing
Optional routing sugar for TelegramBotKit (ASP.NET-style Use* methods). |
GitHub repositories
This package is not used by any popular GitHub repositories.