Files
Telegrator/Telegrator.Hosting.Web
Rikitav bf66431089 * Added "INamedFilter" to tagging filters. Required for fallbacking system
* AnonymousCompiledFilter now has undependent realization
* All internal filters now implement INamedFilter interface
* Added new static methods to "Filter" class
* Added Filters fallbacking system
* Added "FiltersFallback" method in "UpdatehandlerBase"
* Changed filters validating system to be able to report failed filters
* Added "FiltersFallbackReport" class
* Added "FormReport" Property to "UpdateHandlerAttributeBase"
* Version incremented
2025-08-08 17:04:56 +04:00
..
2025-08-02 03:36:48 +04:00

Telegrator.Hosting.Web

Telegrator.Hosting.Web is an extension for the Telegrator framework that enables seamless integration with ASP.NET Core and webhook-based Telegram bots. It is designed for scalable, production-ready web applications.


Features

  • ASP.NET Core integration for webhook-based bots
  • Automatic handler discovery and registration
  • Strongly-typed configuration via appsettings.json and environment variables
  • Dependency injection and middleware support
  • Graceful startup/shutdown and lifecycle management
  • Advanced error handling and logging
  • Supports all Telegrator handler/filter/state features

Requirements

  • .NET 8.0 or later
  • ASP.NET Core

Installation

dotnet add package Telegrator.Hosting.Web

Quick Start Example

Program.cs (ASP.NET Core):

using Telegrator.Hosting;
using Telegrator.Hosting.Web;

// Creating builder
TelegramBotWebHostBuilder builder = TelegramBotWebHost.CreateBuilder(new TelegramBotWebOptions()
{
    Args = args,
    ExceptIntersectingCommandAliases = true
});

// Register handlers
builder.Handlers.CollectHandlersAssemblyWide();
builder.Services.AddHandlersFromAssembly(typeof(Program).Assembly);

// Register your services
builder.Services.AddSingleton<IMyService, MyService>();

// Building and running application
TelegramBotWebHost telegramBot = builder.Build();
telegramBot.SetBotCommands();
telegramBot.Run();

Configuration (appsettings.json)

{
  "TelegramBotClientOptions": {
    "Token": "YOUR_BOT_TOKEN"
  }

  "TelegratorWebOptions": {
    "WebhookUri" = "https://you-public-host.ru/bot",
    "DropPendingUpdates": true
  }
}
  • TelegramBotClientOptions: Bot token and client settings

Documentation


License

GPLv3