TelegramBotKit.Generators 0.3.2

dotnet add package TelegramBotKit.Generators --version 0.3.2
                    
NuGet\Install-Package TelegramBotKit.Generators -Version 0.3.2
                    
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.Generators" Version="0.3.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TelegramBotKit.Generators" Version="0.3.2" />
                    
Directory.Packages.props
<PackageReference Include="TelegramBotKit.Generators" />
                    
Project file
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.Generators --version 0.3.2
                    
#r "nuget: TelegramBotKit.Generators, 0.3.2"
                    
#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.Generators@0.3.2
                    
#: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.Generators&version=0.3.2
                    
Install as a Cake Addin
#tool nuget:?package=TelegramBotKit.Generators&version=0.3.2
                    
Install as a Cake Tool

TelegramBotKit

TelegramBotKit is a lightweight toolkit for building Telegram bots on .NET with a structured update pipeline, typed handlers, and simple command routing.

📚 Start here: Documentation index

Packages

  • TelegramBotKit — core pipeline, dispatching, commands, messaging helpers.
  • TelegramBotKit.Hosting — polling/hosting integration.
  • TelegramBotKit.Routing — optional ASP.NET-style Use* routing sugar.
  • TelegramBotKit.Generators — optional Roslyn source generator for compile-time AddCommands() registration.

Features

  • Middleware pipeline for update processing.
  • Typed update payload handlers (IUpdatePayloadHandler<TPayload>).
  • Message/text/callback commands (attributes + optional routing sugar).
  • WaitForUserResponse helper for request/response flows.
  • IMessageSender facade for sending messages.
  • Optional queued sender to reduce rate-limit errors.

Requirements

  • .NET 10 (current target framework is net10.0).

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)

  1. Add configuration.

Create appsettings.json:

{
  "TelegramBotKit": {
    "Token": "PUT_YOUR_BOT_TOKEN_HERE",
    "Polling": {
      "MaxDegreeOfParallelism": 4,
      "Limit": 100,
      "TimeoutSeconds": 10,
      "AllowedUpdates": []
    }
  }
}

AllowedUpdates: [] means “allow all update types”. If you want only specific types, list them explicitly.

  1. 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();

// Optional: queued sender (helps with Telegram rate limits)
bot.UseQueuedMessageSender();

builder.Services.AddTelegramBotKitPolling();

var host = builder.Build();
await host.RunAsync();

Need a custom HttpClient for proxy, timeout, or custom handlers? See Quick start.

  1. 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

Running the sample

dotnet run --project samples/TelegramBotKit.Sample.ConsolePolling
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

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.2 113 3/30/2026
0.3.1 106 2/22/2026
0.3.0 113 1/18/2026