cnet 1.7.0

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

cnet

cnet

CI NuGet Downloads License .NET 9 Bot API 10.1

Telegram bot toolkit for .NET 9 — strongly typed handlers, built-in flood control and automatic retry, sessions and FSM, media-group aggregation, long polling, and hardened webhooks.

Quick start

var builder = Host.CreateApplicationBuilder(args);

builder.Services
    .AddCnet(options => options.BotToken = builder.Configuration["BotToken"]!)
    .UseReplayGuard()
    .OnCommand("start", async cmd =>
    {
        var keyboard = Keyboard.Inline()
            .Row().Callback("Help", "help").Url("Site", "https://example.com")
            .Build();

        await cmd.ReplyAsync("<b>Hello!</b>", keyboard);
    })
    .OnCallback("help", async cb =>
    {
        await cb.AnswerAsync();
        await cb.EditTextAsync("Help text");
    })
    .OnMessage(async msg =>
    {
        await msg.TypingAsync();
        await msg.ReplyQuotedAsync("Echo: " + msg.Text);
    })
    .UsePolling();

await builder.Build().RunAsync();

For webhooks, add the cnet.aspnetcore package:

builder.Services.AddCnetWebhook(options =>
{
    options.PublicUrl = "https://bot.example.com";
    options.Path = "/telegram/webhook";
    options.SecretToken = configuration["WebhookSecret"]!;
});

app.MapCnetWebhook();

Highlights

  • Typed turns: command, callback, message, and album handlers each receive a dedicated context with exactly the operations that interaction supports
  • Automatic retry on 429 (retry_after respected) and transient network errors
  • Proactive outbound throttle: 30 msg/s global, 1 msg/s per chat, on by default
  • Sessions and FSM with OnState(...) routing and pluggable storage
  • Media-group aggregation: whole albums arrive as one event
  • Inbound per-user rate limiting, replay protection, global error hook
  • Class-based handlers with constructor injection
  • Bounded update queue with backpressure and graceful shutdown
  • Wrappers for every common send and management operation, plus ctx.Bot for direct IntelliSense access to all 180+ Bot API 10.1 methods (rich messages, guardian bots, gifts, business accounts) with the same retry policy

Documentation

License

Released under the MIT License. Telegram is a trademark of Telegram FZ-LLC; this project is independent and not affiliated with or endorsed by Telegram.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on cnet:

Package Downloads
cnet.aspnetcore

ASP.NET Core webhook integration for the cnet Telegram toolkit: secure webhook endpoint with secret-token validation and automatic webhook registration.

cnet.metrics

OpenTelemetry-compatible metrics for the cnet Telegram toolkit: update counts, processing latency, and failure counters exposed through a standard System.Diagnostics.Metrics meter.

cnet.redis

Redis backing for the cnet Telegram toolkit: durable update queue (Redis Streams), distributed replay protection, and shared session storage — everything a multi-instance bot needs.

cnet.testing

Test harness for cnet Telegram bots: drive commands, messages, and callbacks through your real handler pipeline with a fake bot client, and assert on the outgoing requests — no Telegram connection required.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.7.0 181 7/9/2026
1.6.0 149 7/9/2026
1.5.0 150 7/9/2026
1.4.0 118 7/9/2026
1.3.0 121 7/9/2026
1.2.2 150 7/9/2026
1.2.1 114 7/9/2026
1.2.0 142 7/9/2026