Telegrator 1.0.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package Telegrator --version 1.0.4
                    
NuGet\Install-Package Telegrator -Version 1.0.4
                    
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="Telegrator" Version="1.0.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Telegrator" Version="1.0.4" />
                    
Directory.Packages.props
<PackageReference Include="Telegrator" />
                    
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 Telegrator --version 1.0.4
                    
#r "nuget: Telegrator, 1.0.4"
                    
#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 Telegrator@1.0.4
                    
#: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=Telegrator&version=1.0.4
                    
Install as a Cake Addin
#tool nuget:?package=Telegrator&version=1.0.4
                    
Install as a Cake Tool

Telegrator

Telegrator Banner

A modern reactive framework for Telegram bots in C# with aspect-oriented design, mediator-based dispatching, and flexible architecture.


🚀 About Telegrator

Telegrator is a next-generation framework for building Telegram bots in C#, inspired by AOP (Aspect-Oriented Programming) and the mediator pattern. It enables decentralized, easily extensible, and maintainable bot logic without traditional state machines or monolithic handlers.


✨ Key Features

  • Aspect-oriented approach: Handlers and filters are "aspects" of the bot, easily composable and extendable.
  • Decentralized logic: Each handler is an independent module—no more giant switch/case blocks.
  • Mediator-based dispatching: All updates are routed through a powerful mediator-dispatcher.
  • Flexible filtering: Filters for commands, text, sender, chat, regex, and much more.
  • Execution order and priorities: Easily control handler priorities and execution order.
  • Thread safety and concurrency control: Limit the number of concurrent handlers, await other updates inside a handler.
  • Extensibility via attributes and providers: Easily add your own filters, handlers, and state keepers.
  • Minimal boilerplate—maximum declarativity!

🧩 Architecture & Approach

  • Decentralization: Bot logic is split into independent handlers (aspects), each responsible for its own part.
  • Mediator: All Telegram updates go through a mediator, which decides which handlers should process them and in what order.
  • Filters: Describe handler trigger conditions in a flexible, declarative way.
  • State: Built-in mechanisms for user/chat state without manual state machines.

🛠️ Quick Start

1. Installation

# .NET CLI
dotnet add package Telegrator

# NuGet CLI
NuGet\Install-Package Telegrator

2. Minimal Bot Example

using Telegrator.Handlers;
using Telegrator.Annotations;

[MessageHandler]
public class HelloHandler : MessageHandler
{
    public override async Task Execute(IAbstractHandlerContainer<Message> container, CancellationToken cancellation)
    {
        await Reply("Hello, world!", cancellationToken: cancellation);
    }
}

// Registration and launch:
var bot = new TelegratorClient("<YOUR_BOT_TOKEN>");
bot.Handlers.AddHandler<HelloHandler>();
bot.StartReceiving();

3. Adding Filtering and Commands

using Telegram.Bot.Types.Enums;
using Telegrator.Handlers;
using Telegrator.Annotations;

[CommandHandler, CommandAllias("start", "hello"), ChatType(ChatType.Private)]
public class StartCommandHandler : CommandHandler
{
    public override async Task Execute(IAbstractHandlerContainer<Message> container, CancellationToken cancellation)
    {
        await Responce("Welcome!", cancellationToken: cancellation);
    }
}

// Registration:
bot.Handlers.AddHandler<StartCommandHandler>();

4. State Management Example

using Telegrator.Handlers;
using Telegrator.Annotations;

[CommandHandler, CommandAllias("first"), NumericState(SpecialState.NoState)]
public class StateKeepFirst : CommandHandler
{
    public override async Task Execute(IAbstractHandlerContainer<Message> container, CancellationToken cancellation)
    {
        container.CreateNumericState();
        container.ForwardNumericState();
        await Reply("first state moved (1)", cancellationToken: cancellation);
    }
}

// Registration:
bot.Handlers.AddHandler<StateKeepFirst>();

🏆 Why Telegrator over state machines?

  • No tangled switch/case—logic is split into independent handlers.
  • Flexible dispatching—the mediator decides who and when processes an event.
  • Simple state management—no need to implement state machines manually.
  • Easy scaling—add new handlers without rewriting old ones.
  • High code readability and maintainability.

📚 Documentation & Examples


🤝 Contribution & Feedback

We welcome your questions, suggestions, and pull requests! Open issues or contact us directly.


⚡ License

GPLv3

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Telegrator:

Package Downloads
Telegrator.Hosting

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.15.9 229 8/24/2025
1.15.8 220 8/24/2025
1.15.7 82 8/23/2025
1.15.6 149 8/21/2025
1.15.5 155 8/19/2025
1.15.4 145 8/19/2025
1.15.3 147 8/19/2025
1.15.2 198 8/18/2025
1.15.1 144 8/18/2025
1.15.0 146 8/18/2025
1.0.13 154 8/11/2025
1.0.12 199 8/8/2025
1.0.11 138 8/4/2025
1.0.10 75 8/2/2025
1.0.9 47 8/1/2025
1.0.8.1 84 8/1/2025
1.0.8 88 8/1/2025
1.0.7 103 7/28/2025
1.0.6 112 7/28/2025
1.0.5 112 7/27/2025
1.0.4 122 7/27/2025
1.0.3 159 7/27/2025 1.0.3 is deprecated because it has critical bugs.
1.0.2 262 7/26/2025 1.0.2 is deprecated because it has critical bugs.
1.0.1 406 7/25/2025 1.0.1 is deprecated because it has critical bugs.
1.0.0 542 7/24/2025 1.0.0 is deprecated because it has critical bugs.