6 Commits

Author SHA1 Message Date
Rikitav e28cc2b8da Removed test application 2026-03-08 23:17:52 +04:00
Rikitav c6cda703ef version incremented 2026-03-08 22:02:30 +04:00
Rikitav 401c8d02aa fixed double UseTelegrator invokation 2026-03-08 22:02:01 +04:00
Rikitav 2cf4910abd * fixed loop dependency
* fixed router not getting result
* fixed hosts configuration
2026-03-08 21:59:50 +04:00
Rikitav 81da5e0bc7 * fixed loop dependency
* fixed router not getting result
* fixed hosts configuration
2026-03-08 19:43:48 +04:00
Rikitav b42e03fe06 docs updated 2026-03-07 23:38:14 +04:00
24 changed files with 225 additions and 167 deletions
+2 -2
View File
@@ -361,5 +361,5 @@ MigrationBackup/
# Fody - auto-generated XML schema # Fody - auto-generated XML schema
FodyWeavers.xsd FodyWeavers.xsd
/GETTING_STARTED.md
/ANNOTATION_OVERVIEW.md .aider*
+1 -5
View File
@@ -1,14 +1,10 @@
# Telegrator
![Telegrator Banner](https://github.com/Rikitav/Telegrator/blob/master/resources%2FTelegrator_banner.png) ![Telegrator Banner](https://github.com/Rikitav/Telegrator/blob/master/resources%2FTelegrator_banner.png)
> **A modern reactive framework for Telegram bots in C# with aspect-oriented design, mediator-based dispatching, and flexible architecture.**
--- ---
## 🚀 About Telegrator ## 🚀 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. Telegrator is a modern C# framework for building Telegram bots, 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.
--- ---
+35 -29
View File
@@ -1078,7 +1078,7 @@ var host = webHost.Build();
await host.StartAsync(); await host.StartAsync();
``` ```
**Note:** For web hosting, you need to configure both `TelegramBotClientOptions` (for bot token) and `TelegratorWebOptions` (for webhook settings) in your `appsettings.json` file. **Note:** For web hosting, you need to configure both `TelegratorOptions` (for bot token) and `WebhookerOptions` (for webhook settings) in your `appsettings.json` file.
> **How is it working?** > **How is it working?**
> 1. **Console Integration**: `TelegratorClient` provides a simple way to create bots in console applications. > 1. **Console Integration**: `TelegratorClient` provides a simple way to create bots in console applications.
@@ -1723,12 +1723,11 @@ dotnet add package Telegrator.Hosting.Web
**Core Components:** **Core Components:**
- `TelegramBotWebHost` - The main web hosted service for webhook handling - `TelegramBotWebHost` - The main web hosted service for webhook handling
- `TelegramBotWebHostBuilder` - Builder pattern for configuring the web host - `TelegramBotWebHostBuilder` - Builder pattern for configuring the web host
- `TelegramBotWebOptions` - Configuration options for web application settings - `WebhookerOptions` - Configuration options for webhook settings
- `TelegratorWebOptions` - Configuration options for webhook settings
**Configuration Requirements:** **Configuration Requirements:**
- `TelegramBotClientOptions` must be configured as it contains the bot token - `TelegratorOptions` must be configured as it contains the bot token
- `TelegratorWebOptions` must be configured through external sources (appsettings.json) for webhook settings - `WebhookerOptions` must be configured through external sources (appsettings.json) for webhook settings
**Basic Example:** **Basic Example:**
```csharp ```csharp
@@ -1750,11 +1749,11 @@ await host.StartAsync();
**Configuration via appsettings.json:** **Configuration via appsettings.json:**
```json ```json
{ {
"TelegramBotClientOptions": { "TelegratorOptions": {
"Token": "YOUR_BOT_TOKEN" "Token": "YOUR_BOT_TOKEN"
}, },
"TelegratorWebOptions": { "WebhookerOptions": {
"WebhookUri": "https://your-domain.com/webhook", "WebhookUri": "https://your-domain.com/webhook",
"SecretToken": "your-secret-token", "SecretToken": "your-secret-token",
"MaxConnections": 40, "MaxConnections": 40,
@@ -1790,7 +1789,7 @@ The bot token must be configured either in `appsettings.json` or through environ
```json ```json
{ {
"TelegramBotClientOptions": { "TelegratorOptions": {
"Token": "YOUR_BOT_TOKEN" "Token": "YOUR_BOT_TOKEN"
} }
} }
@@ -1805,7 +1804,7 @@ export TelegramBotClientOptions__Token="YOUR_BOT_TOKEN"
**Advanced Configuration:** **Advanced Configuration:**
```json ```json
{ {
"TelegramBotClientOptions": { "TelegratorOptions": {
"Token": "YOUR_BOT_TOKEN", "Token": "YOUR_BOT_TOKEN",
"BaseUrl": "https://api.telegram.org" "BaseUrl": "https://api.telegram.org"
}, },
@@ -2158,10 +2157,11 @@ await host.StartAsync();
**Configuration (appsettings.json):** **Configuration (appsettings.json):**
```json ```json
{ {
"TelegramBotClientOptions": { "TelegratorOptions": {
"Token": "YOUR_BOT_TOKEN" "Token": "YOUR_BOT_TOKEN"
}, },
"TelegratorWebOptions": {
"WebhookerOptions": {
"WebhookUri": "https://your-domain.com/webhook", "WebhookUri": "https://your-domain.com/webhook",
"SecretToken": "your-secret-token", "SecretToken": "your-secret-token",
"MaxConnections": 40, "MaxConnections": 40,
@@ -2283,12 +2283,12 @@ public class StartWizardHandler : CommandHandler
### 7.5. Logging System ### 7.5. Logging System
Telegrator provides a centralized logging system called "Alligator" that allows integration with various logging frameworks while maintaining zero dependencies in the core library. Telegrator provides a centralized logging system called "TelegratorLogging" that allows integration with various logging frameworks while maintaining zero dependencies in the core library.
#### Overview #### Overview
The logging system consists of: The logging system consists of:
- **Alligator** - Centralized static logging system - **TelegratorLogging** - Centralized static logging system
- **ITelegratorLogger** - Core logging interface - **ITelegratorLogger** - Core logging interface
- **NullLogger** - No-op logger - **NullLogger** - No-op logger
- **ConsoleLogger** - Simple console output - **ConsoleLogger** - Simple console output
@@ -2301,11 +2301,11 @@ The logging system consists of:
using Telegrator.Logging; using Telegrator.Logging;
// Add console adapter // Add console adapter
Alligator.AddAdapter(new ConsoleLoggerAdapter(LogLevel.Debug, includeTimestamp: true)); TelegratorLogging.AddAdapter(new ConsoleLoggerAdapter(LogLevel.Debug, includeTimestamp: true));
// Use logging // Use logging
Alligator.LogInformation("Bot started"); TelegratorLogging.LogInformation("Bot started");
Alligator.LogError("Something went wrong", exception); TelegratorLogging.LogError("Something went wrong", exception);
``` ```
**Custom Logger Adapter:** **Custom Logger Adapter:**
@@ -2322,7 +2322,7 @@ public class CustomLogger : ITelegratorLogger
} }
// Add custom adapter // Add custom adapter
Alligator.AddAdapter(new CustomLogger()); TelegratorLogging.AddAdapter(new CustomLogger());
``` ```
#### Hosting Integration #### Hosting Integration
@@ -2340,7 +2340,7 @@ var loggerFactory = LoggerFactory.Create(builder =>
// Add Microsoft.Extensions.Logging adapter // Add Microsoft.Extensions.Logging adapter
ILogger<Program> logger = loggerFactory.CreateLogger<Program>(); ILogger<Program> logger = loggerFactory.CreateLogger<Program>();
MicrosoftLoggingAdapter adapter = new MicrosoftLoggingAdapter(logger); MicrosoftLoggingAdapter adapter = new MicrosoftLoggingAdapter(logger);
Alligator.AddAdapter(adapter); TelegratorLogging.AddAdapter(adapter);
var bot = new TelegratorClient("<BOT_TOKEN>"); var bot = new TelegratorClient("<BOT_TOKEN>");
``` ```
@@ -2359,14 +2359,14 @@ All logging methods support simple message logging:
```csharp ```csharp
// In your handlers or aspects // In your handlers or aspects
Alligator.LogInformation("Handler executed"); TelegratorLogging.LogInformation("Handler executed");
Alligator.LogError("Something went wrong", exception); TelegratorLogging.LogError("Something went wrong", exception);
Alligator.LogWarning("User exceeded rate limit"); TelegratorLogging.LogWarning("User exceeded rate limit");
``` ```
#### Performance Considerations #### Performance Considerations
- **Alligator** has minimal overhead with thread-safe adapter management - **TelegratorLogging** has minimal overhead with thread-safe adapter management
- **NullLogger** has zero overhead - **NullLogger** has zero overhead
- **ConsoleLogger** is lightweight for development - **ConsoleLogger** is lightweight for development
- **MicrosoftLoggingAdapter** delegates to the underlying framework - **MicrosoftLoggingAdapter** delegates to the underlying framework
@@ -2576,11 +2576,11 @@ For detailed information about the logging system, see [section 7.5 - Logging Sy
using Telegrator.Logging; using Telegrator.Logging;
// Add console adapter for debugging // Add console adapter for debugging
Alligator.AddConsoleAdapter(LogLevel.Debug, includeTimestamp: true); TelegratorLogging.AddConsoleAdapter(LogLevel.Debug, includeTimestamp: true);
// Use logging // Use logging
Alligator.LogInformation("Bot started"); TelegratorLogging.LogInformation("Bot started");
Alligator.LogError("Something went wrong", exception); TelegratorLogging.LogError("Something went wrong", exception);
``` ```
#### Common Debugging Steps #### Common Debugging Steps
@@ -2599,9 +2599,9 @@ Alligator.LogError("Something went wrong", exception);
#### Simple Logging #### Simple Logging
```csharp ```csharp
// In your handlers or aspects // In your handlers or aspects
Alligator.LogInformation("Handler executed"); TelegratorLogging.LogInformation("Handler executed");
Alligator.LogError("Something went wrong", exception); TelegratorLogging.LogError("Something went wrong", exception);
Alligator.LogWarning("User exceeded rate limit"); TelegratorLogging.LogWarning("User exceeded rate limit");
``` ```
--- ---
@@ -2617,4 +2617,10 @@ Alligator.LogWarning("User exceeded rate limit");
> **Feel free to contribute, ask questions, or open issues!** > **Feel free to contribute, ask questions, or open issues!**
Сишарпилло Крокодилло В главных ролях :
> Сишарпилло Крокодилло,
> Дыкий Сишарп,
> Шарпенко Михаил Дотнетович
Кастинг и Тестирование :
> не проводилось
+27 -1
View File
@@ -100,6 +100,12 @@
<member name="P:Telegrator.Hosting.Web.TelegramBotWebHostBuilder.Environment"> <member name="P:Telegrator.Hosting.Web.TelegramBotWebHostBuilder.Environment">
<inheritdoc/> <inheritdoc/>
</member> </member>
<member name="P:Telegrator.Hosting.Web.TelegramBotWebHostBuilder.Properties">
<inheritdoc/>
</member>
<member name="P:Telegrator.Hosting.Web.TelegramBotWebHostBuilder.Metrics">
<inheritdoc/>
</member>
<member name="M:Telegrator.Hosting.Web.TelegramBotWebHostBuilder.#ctor(Microsoft.AspNetCore.Builder.WebApplicationBuilder,Microsoft.AspNetCore.Builder.WebApplicationOptions)"> <member name="M:Telegrator.Hosting.Web.TelegramBotWebHostBuilder.#ctor(Microsoft.AspNetCore.Builder.WebApplicationBuilder,Microsoft.AspNetCore.Builder.WebApplicationOptions)">
<summary> <summary>
Initializes a new instance of the <see cref="T:Telegrator.Hosting.Web.TelegramBotWebHostBuilder"/> class. Initializes a new instance of the <see cref="T:Telegrator.Hosting.Web.TelegramBotWebHostBuilder"/> class.
@@ -107,6 +113,14 @@
<param name="webApplicationBuilder"></param> <param name="webApplicationBuilder"></param>
<param name="settings"></param> <param name="settings"></param>
</member> </member>
<member name="M:Telegrator.Hosting.Web.TelegramBotWebHostBuilder.#ctor(Microsoft.AspNetCore.Builder.WebApplicationBuilder,Telegrator.TelegratorOptions,Microsoft.AspNetCore.Builder.WebApplicationOptions)">
<summary>
Initializes a new instance of the <see cref="T:Telegrator.Hosting.Web.TelegramBotWebHostBuilder"/> class.
</summary>
<param name="webApplicationBuilder"></param>
<param name="options"></param>
<param name="settings"></param>
</member>
<member name="M:Telegrator.Hosting.Web.TelegramBotWebHostBuilder.#ctor(Microsoft.AspNetCore.Builder.WebApplicationBuilder,Telegrator.Core.IHandlersCollection,Microsoft.AspNetCore.Builder.WebApplicationOptions)"> <member name="M:Telegrator.Hosting.Web.TelegramBotWebHostBuilder.#ctor(Microsoft.AspNetCore.Builder.WebApplicationBuilder,Telegrator.Core.IHandlersCollection,Microsoft.AspNetCore.Builder.WebApplicationOptions)">
<summary> <summary>
Initializes a new instance of the <see cref="T:Telegrator.Hosting.Web.TelegramBotWebHostBuilder"/> class. Initializes a new instance of the <see cref="T:Telegrator.Hosting.Web.TelegramBotWebHostBuilder"/> class.
@@ -115,12 +129,24 @@
<param name="handlers"></param> <param name="handlers"></param>
<param name="settings"></param> <param name="settings"></param>
</member> </member>
<member name="M:Telegrator.Hosting.Web.TelegramBotWebHostBuilder.#ctor(Microsoft.AspNetCore.Builder.WebApplicationBuilder,Telegrator.Core.IHandlersCollection,Telegrator.TelegratorOptions,Microsoft.AspNetCore.Builder.WebApplicationOptions)">
<summary>
Initializes a new instance of the <see cref="T:Telegrator.Hosting.Web.TelegramBotWebHostBuilder"/> class.
</summary>
<param name="webApplicationBuilder"></param>
<param name="handlers"></param>
<param name="options"></param>
<param name="settings"></param>
</member>
<member name="M:Telegrator.Hosting.Web.TelegramBotWebHostBuilder.Build"> <member name="M:Telegrator.Hosting.Web.TelegramBotWebHostBuilder.Build">
<summary> <summary>
Builds the host. Builds the host.
</summary> </summary>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Telegrator.Hosting.Web.TelegramBotWebHostBuilder.ConfigureContainer``1(Microsoft.Extensions.DependencyInjection.IServiceProviderFactory{``0},System.Action{``0})">
<inheritdoc/>
</member>
<member name="T:Telegrator.Hosting.Web.WebhookerOptions"> <member name="T:Telegrator.Hosting.Web.WebhookerOptions">
<summary> <summary>
Configuration options for Telegram bot behavior and execution settings. Configuration options for Telegram bot behavior and execution settings.
@@ -185,7 +211,7 @@
<member name="M:Telegrator.ServicesCollectionExtensions.get_Handlers(Microsoft.AspNetCore.Builder.WebApplicationBuilder)"> <member name="M:Telegrator.ServicesCollectionExtensions.get_Handlers(Microsoft.AspNetCore.Builder.WebApplicationBuilder)">
<inheritdoc cref="P:Telegrator.ServicesCollectionExtensions.&lt;G&gt;$41F16C2D39AF52899E745C9C9F42FF83.Handlers"/> <inheritdoc cref="P:Telegrator.ServicesCollectionExtensions.&lt;G&gt;$41F16C2D39AF52899E745C9C9F42FF83.Handlers"/>
</member> </member>
<member name="M:Telegrator.ServicesCollectionExtensions.AddTelegratorWeb(Microsoft.Extensions.Hosting.IHostApplicationBuilder,Microsoft.AspNetCore.Builder.WebApplicationOptions,Telegrator.TelegratorOptions,Telegrator.Core.IHandlersCollection)"> <member name="M:Telegrator.ServicesCollectionExtensions.AddTelegratorWeb(Microsoft.Extensions.Hosting.IHostApplicationBuilder,Telegrator.TelegratorOptions,Telegrator.Core.IHandlersCollection)">
<summary> <summary>
Replaces TelegramBotWebHostBuilder. Configures DI, options, and handlers. Replaces TelegramBotWebHostBuilder. Configures DI, options, and handlers.
</summary> </summary>
+29 -30
View File
@@ -13,7 +13,7 @@
<param name="services"></param> <param name="services"></param>
<param name="configuration"></param> <param name="configuration"></param>
</member> </member>
<member name="M:Telegrator.Hosting.HostedTelegramBotInfo.#ctor(Telegram.Bot.ITelegramBotClient,System.IServiceProvider,Microsoft.Extensions.Configuration.IConfigurationManager)"> <member name="M:Telegrator.Hosting.HostedTelegramBotInfo.#ctor(Telegram.Bot.ITelegramBotClient,System.IServiceProvider,Microsoft.Extensions.Configuration.IConfiguration)">
<summary> <summary>
Implementation of <see cref="T:Telegrator.Core.ITelegramBotInfo"/> that provides bot information. Implementation of <see cref="T:Telegrator.Core.ITelegramBotInfo"/> that provides bot information.
Contains metadata about the Telegram bot including user details and service provider for wider filterring abilities Contains metadata about the Telegram bot including user details and service provider for wider filterring abilities
@@ -35,27 +35,6 @@
Provides access to configuration of this Hosted telegram bot Provides access to configuration of this Hosted telegram bot
</summary> </summary>
</member> </member>
<member name="T:Telegrator.Hosting.ITelegramBotHostBuilder">
<summary>
Interface for building Telegram bot hosts with dependency injection support.
Combines host application building capabilities with handler collection functionality.
</summary>
</member>
<member name="P:Telegrator.Hosting.ITelegramBotHostBuilder.Configuration">
<summary>
Gets the set of key/value configuration properties.
</summary>
</member>
<member name="P:Telegrator.Hosting.ITelegramBotHostBuilder.Logging">
<summary>
Gets a collection of logging providers for the application to compose. This is useful for adding new logging providers.
</summary>
</member>
<member name="P:Telegrator.Hosting.ITelegramBotHostBuilder.Services">
<summary>
Gets a collection of services for the application to compose. This is useful for adding user provided or framework provided services.
</summary>
</member>
<member name="T:Telegrator.Hosting.TelegramBotHost"> <member name="T:Telegrator.Hosting.TelegramBotHost">
<summary> <summary>
Represents a hosted telegram bot Represents a hosted telegram bot
@@ -133,6 +112,12 @@
<member name="P:Telegrator.Hosting.TelegramBotHostBuilder.Environment"> <member name="P:Telegrator.Hosting.TelegramBotHostBuilder.Environment">
<inheritdoc/> <inheritdoc/>
</member> </member>
<member name="P:Telegrator.Hosting.TelegramBotHostBuilder.Properties">
<inheritdoc/>
</member>
<member name="P:Telegrator.Hosting.TelegramBotHostBuilder.Metrics">
<inheritdoc/>
</member>
<member name="M:Telegrator.Hosting.TelegramBotHostBuilder.#ctor(Microsoft.Extensions.Hosting.HostApplicationBuilder,Microsoft.Extensions.Hosting.HostApplicationBuilderSettings)"> <member name="M:Telegrator.Hosting.TelegramBotHostBuilder.#ctor(Microsoft.Extensions.Hosting.HostApplicationBuilder,Microsoft.Extensions.Hosting.HostApplicationBuilderSettings)">
<summary> <summary>
Initializes a new instance of the <see cref="T:Telegrator.Hosting.TelegramBotHostBuilder"/> class. Initializes a new instance of the <see cref="T:Telegrator.Hosting.TelegramBotHostBuilder"/> class.
@@ -140,6 +125,14 @@
<param name="hostApplicationBuilder"></param> <param name="hostApplicationBuilder"></param>
<param name="settings"></param> <param name="settings"></param>
</member> </member>
<member name="M:Telegrator.Hosting.TelegramBotHostBuilder.#ctor(Microsoft.Extensions.Hosting.HostApplicationBuilder,Telegrator.TelegratorOptions,Microsoft.Extensions.Hosting.HostApplicationBuilderSettings)">
<summary>
Initializes a new instance of the <see cref="T:Telegrator.Hosting.TelegramBotHostBuilder"/> class.
</summary>
<param name="hostApplicationBuilder"></param>
<param name="options"></param>
<param name="settings"></param>
</member>
<member name="M:Telegrator.Hosting.TelegramBotHostBuilder.#ctor(Microsoft.Extensions.Hosting.HostApplicationBuilder,Telegrator.Core.IHandlersCollection,Microsoft.Extensions.Hosting.HostApplicationBuilderSettings)"> <member name="M:Telegrator.Hosting.TelegramBotHostBuilder.#ctor(Microsoft.Extensions.Hosting.HostApplicationBuilder,Telegrator.Core.IHandlersCollection,Microsoft.Extensions.Hosting.HostApplicationBuilderSettings)">
<summary> <summary>
Initializes a new instance of the <see cref="T:Telegrator.Hosting.TelegramBotHostBuilder"/> class. Initializes a new instance of the <see cref="T:Telegrator.Hosting.TelegramBotHostBuilder"/> class.
@@ -148,12 +141,24 @@
<param name="handlers"></param> <param name="handlers"></param>
<param name="settings"></param> <param name="settings"></param>
</member> </member>
<member name="M:Telegrator.Hosting.TelegramBotHostBuilder.#ctor(Microsoft.Extensions.Hosting.HostApplicationBuilder,Telegrator.Core.IHandlersCollection,Telegrator.TelegratorOptions,Microsoft.Extensions.Hosting.HostApplicationBuilderSettings)">
<summary>
Initializes a new instance of the <see cref="T:Telegrator.Hosting.TelegramBotHostBuilder"/> class.
</summary>
<param name="hostApplicationBuilder"></param>
<param name="handlers"></param>
<param name="options"></param>
<param name="settings"></param>
</member>
<member name="M:Telegrator.Hosting.TelegramBotHostBuilder.Build"> <member name="M:Telegrator.Hosting.TelegramBotHostBuilder.Build">
<summary> <summary>
Builds the host. Builds the host.
</summary> </summary>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Telegrator.Hosting.TelegramBotHostBuilder.ConfigureContainer``1(Microsoft.Extensions.DependencyInjection.IServiceProviderFactory{``0},System.Action{``0})">
<inheritdoc/>
</member>
<member name="T:Telegrator.Logging.MicrosoftLoggingAdapter"> <member name="T:Telegrator.Logging.MicrosoftLoggingAdapter">
<summary> <summary>
Adapter for Microsoft.Extensions.Logging to work with Telegrator logging system. Adapter for Microsoft.Extensions.Logging to work with Telegrator logging system.
@@ -190,12 +195,6 @@
<member name="M:Telegrator.Polling.HostedUpdateReceiver.ExecuteAsync(System.Threading.CancellationToken)"> <member name="M:Telegrator.Polling.HostedUpdateReceiver.ExecuteAsync(System.Threading.CancellationToken)">
<inheritdoc/> <inheritdoc/>
</member> </member>
<member name="T:Telegrator.Polling.HostUpdateHandlersPool">
<inheritdoc/>
</member>
<member name="M:Telegrator.Polling.HostUpdateHandlersPool.#ctor(Telegrator.Core.IUpdateRouter,Microsoft.Extensions.Options.IOptions{Telegrator.TelegratorOptions})">
<inheritdoc/>
</member>
<member name="T:Telegrator.Polling.HostUpdateRouter"> <member name="T:Telegrator.Polling.HostUpdateRouter">
<inheritdoc/> <inheritdoc/>
</member> </member>
@@ -204,7 +203,7 @@
<see cref="T:Microsoft.Extensions.Logging.ILogger"/> of this router <see cref="T:Microsoft.Extensions.Logging.ILogger"/> of this router
</summary> </summary>
</member> </member>
<member name="M:Telegrator.Polling.HostUpdateRouter.#ctor(Telegrator.Core.IHandlersProvider,Telegrator.Core.IAwaitingProvider,Microsoft.Extensions.Options.IOptions{Telegrator.TelegratorOptions},Telegrator.Core.IUpdateHandlersPool,Telegrator.Core.ITelegramBotInfo,Microsoft.Extensions.Logging.ILogger{Telegrator.Polling.HostUpdateRouter})"> <member name="M:Telegrator.Polling.HostUpdateRouter.#ctor(Telegrator.Core.IHandlersProvider,Telegrator.Core.IAwaitingProvider,Microsoft.Extensions.Options.IOptions{Telegrator.TelegratorOptions},Telegrator.Core.ITelegramBotInfo,Microsoft.Extensions.Logging.ILogger{Telegrator.Polling.HostUpdateRouter})">
<inheritdoc/> <inheritdoc/>
</member> </member>
<member name="M:Telegrator.Polling.HostUpdateRouter.HandleUpdateAsync(Telegram.Bot.ITelegramBotClient,Telegram.Bot.Types.Update,System.Threading.CancellationToken)"> <member name="M:Telegrator.Polling.HostUpdateRouter.HandleUpdateAsync(Telegram.Bot.ITelegramBotClient,Telegram.Bot.Types.Update,System.Threading.CancellationToken)">
@@ -259,7 +258,7 @@
<member name="M:Telegrator.HostBuilderExtensions.get_Handlers(Microsoft.Extensions.Hosting.IHostApplicationBuilder)"> <member name="M:Telegrator.HostBuilderExtensions.get_Handlers(Microsoft.Extensions.Hosting.IHostApplicationBuilder)">
<inheritdoc cref="P:Telegrator.HostBuilderExtensions.&lt;G&gt;$605D8CCF64349EA050C790D67C500BD9.Handlers"/> <inheritdoc cref="P:Telegrator.HostBuilderExtensions.&lt;G&gt;$605D8CCF64349EA050C790D67C500BD9.Handlers"/>
</member> </member>
<member name="M:Telegrator.HostBuilderExtensions.AddTelegrator(Microsoft.Extensions.Hosting.IHostApplicationBuilder,Microsoft.Extensions.Hosting.HostApplicationBuilderSettings,Telegrator.TelegratorOptions,Telegrator.Core.IHandlersCollection)"> <member name="M:Telegrator.HostBuilderExtensions.AddTelegrator(Microsoft.Extensions.Hosting.IHostApplicationBuilder,Telegrator.TelegratorOptions,Telegrator.Core.IHandlersCollection)">
<summary> <summary>
Replaces TelegramBotWebHostBuilder. Configures DI, options, and handlers. Replaces TelegramBotWebHostBuilder. Configures DI, options, and handlers.
</summary> </summary>
-10
View File
@@ -6345,16 +6345,6 @@
<param name="options">The bot configuration options.</param> <param name="options">The bot configuration options.</param>
<param name="botInfo"></param> <param name="botInfo"></param>
</member> </member>
<member name="M:Telegrator.Mediation.UpdateRouter.#ctor(Telegrator.Core.IHandlersProvider,Telegrator.Core.IAwaitingProvider,Telegrator.TelegratorOptions,Telegrator.Core.IUpdateHandlersPool,Telegrator.Core.ITelegramBotInfo)">
<summary>
Initializes a new instance of the <see cref="T:Telegrator.Mediation.UpdateRouter"/> class with a custom handlers pool.
</summary>
<param name="handlersProvider">The provider for regular handlers.</param>
<param name="awaitingProvider">The provider for awaiting handlers.</param>
<param name="options">The bot configuration options.</param>
<param name="handlersPool">The custom handlers pool to use.</param>
<param name="botInfo"></param>
</member>
<member name="M:Telegrator.Mediation.UpdateRouter.HandleErrorAsync(Telegram.Bot.ITelegramBotClient,System.Exception,Telegram.Bot.Polling.HandleErrorSource,System.Threading.CancellationToken)"> <member name="M:Telegrator.Mediation.UpdateRouter.HandleErrorAsync(Telegram.Bot.ITelegramBotClient,System.Exception,Telegram.Bot.Polling.HandleErrorSource,System.Threading.CancellationToken)">
<summary> <summary>
Handles errors that occur during update processing. Handles errors that occur during update processing.
+13
View File
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Telegrator" Version="1.16.2"/>
</ItemGroup>
</Project>
+11
View File
@@ -0,0 +1,11 @@
using Telegrator;
namespace Telegrator.Examples;
public class EchoBot
{
public static void Main(string[] args)
{
var client = new TelegratorClient();
}
}
@@ -53,7 +53,6 @@ namespace Telegrator.Hosting.Web
{ {
// Building proxy application // Building proxy application
_innerApp = webApplicationBuilder.Build(); _innerApp = webApplicationBuilder.Build();
_innerApp.UseTelegratorWeb();
// Reruesting services for this host // Reruesting services for this host
_updateRouter = Services.GetRequiredService<IUpdateRouter>(); _updateRouter = Services.GetRequiredService<IUpdateRouter>();
@@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.Metrics;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Telegrator.Core; using Telegrator.Core;
@@ -11,7 +12,7 @@ namespace Telegrator.Hosting.Web
/// <summary> /// <summary>
/// Represents a web hosted telegram bots and services builder that helps manage configuration, logging, lifetime, and more. /// Represents a web hosted telegram bots and services builder that helps manage configuration, logging, lifetime, and more.
/// </summary> /// </summary>
public class TelegramBotWebHostBuilder : ITelegramBotHostBuilder public class TelegramBotWebHostBuilder : IHostApplicationBuilder, ICollectingProvider
{ {
private readonly WebApplicationBuilder _innerBuilder; private readonly WebApplicationBuilder _innerBuilder;
private readonly WebApplicationOptions _settings; private readonly WebApplicationOptions _settings;
@@ -32,17 +33,37 @@ namespace Telegrator.Hosting.Web
/// <inheritdoc/> /// <inheritdoc/>
public IHostEnvironment Environment => _innerBuilder.Environment; public IHostEnvironment Environment => _innerBuilder.Environment;
/// <inheritdoc/>
public IDictionary<object, object> Properties => ((IHostApplicationBuilder)_innerBuilder).Properties;
/// <inheritdoc/>
public IMetricsBuilder Metrics => _innerBuilder.Metrics;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="TelegramBotWebHostBuilder"/> class. /// Initializes a new instance of the <see cref="TelegramBotWebHostBuilder"/> class.
/// </summary> /// </summary>
/// <param name="webApplicationBuilder"></param> /// <param name="webApplicationBuilder"></param>
/// <param name="settings"></param> /// <param name="settings"></param>
public TelegramBotWebHostBuilder(WebApplicationBuilder webApplicationBuilder, WebApplicationOptions settings) public TelegramBotWebHostBuilder(WebApplicationBuilder webApplicationBuilder, WebApplicationOptions? settings = null)
{ {
_innerBuilder = webApplicationBuilder ?? throw new ArgumentNullException(nameof(webApplicationBuilder)); _innerBuilder = webApplicationBuilder ?? throw new ArgumentNullException(nameof(webApplicationBuilder));
_settings = settings ?? throw new ArgumentNullException(nameof(settings)); _settings = settings ?? throw new ArgumentNullException(nameof(settings));
_innerBuilder.AddTelegratorWeb(); this.AddTelegratorWeb();
}
/// <summary>
/// Initializes a new instance of the <see cref="TelegramBotWebHostBuilder"/> class.
/// </summary>
/// <param name="webApplicationBuilder"></param>
/// <param name="options"></param>
/// <param name="settings"></param>
public TelegramBotWebHostBuilder(WebApplicationBuilder webApplicationBuilder, TelegratorOptions? options, WebApplicationOptions? settings)
{
_innerBuilder = webApplicationBuilder ?? throw new ArgumentNullException(nameof(webApplicationBuilder));
_settings = settings ?? throw new ArgumentNullException(nameof(settings));
this.AddTelegratorWeb(options, null);
} }
/// <summary> /// <summary>
@@ -56,7 +77,22 @@ namespace Telegrator.Hosting.Web
_innerBuilder = webApplicationBuilder ?? throw new ArgumentNullException(nameof(webApplicationBuilder)); _innerBuilder = webApplicationBuilder ?? throw new ArgumentNullException(nameof(webApplicationBuilder));
_settings = settings ?? throw new ArgumentNullException(nameof(settings)); _settings = settings ?? throw new ArgumentNullException(nameof(settings));
_innerBuilder.AddTelegratorWeb(null, handlers); this.AddTelegratorWeb(null, handlers);
}
/// <summary>
/// Initializes a new instance of the <see cref="TelegramBotWebHostBuilder"/> class.
/// </summary>
/// <param name="webApplicationBuilder"></param>
/// <param name="handlers"></param>
/// <param name="options"></param>
/// <param name="settings"></param>
public TelegramBotWebHostBuilder(WebApplicationBuilder webApplicationBuilder, IHandlersCollection handlers, TelegratorOptions? options, WebApplicationOptions settings)
{
_innerBuilder = webApplicationBuilder ?? throw new ArgumentNullException(nameof(webApplicationBuilder));
_settings = settings ?? throw new ArgumentNullException(nameof(settings));
this.AddTelegratorWeb(options, handlers);
} }
/// <summary> /// <summary>
@@ -69,5 +105,11 @@ namespace Telegrator.Hosting.Web
host.UseTelegrator(); host.UseTelegrator();
return host; return host;
} }
/// <inheritdoc/>
public void ConfigureContainer<TContainerBuilder>(IServiceProviderFactory<TContainerBuilder> factory, Action<TContainerBuilder>? configure = null) where TContainerBuilder : notnull
{
((IHostApplicationBuilder)_innerBuilder).ConfigureContainer(factory, configure);
}
} }
} }
+5
View File
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Telegrator.Hosting; using Telegrator.Hosting;
using Telegrator.Hosting.Web; using Telegrator.Hosting.Web;
@@ -43,10 +44,14 @@ internal class Program
public static void TelegramBotHostBuilder_Example(string[] args) public static void TelegramBotHostBuilder_Example(string[] args)
{ {
ConfigurationManager configuration = new ConfigurationManager();
configuration.AddJsonFile("appsettings.json");
TelegramBotHostBuilder builder = TelegramBotHost.CreateBuilder(new HostApplicationBuilderSettings() TelegramBotHostBuilder builder = TelegramBotHost.CreateBuilder(new HostApplicationBuilderSettings()
{ {
Args = args, Args = args,
ApplicationName = "TelegramBotHost example", ApplicationName = "TelegramBotHost example",
Configuration = configuration
}); });
builder.Handlers.CollectHandlersAssemblyWide(); builder.Handlers.CollectHandlersAssemblyWide();
@@ -15,7 +15,7 @@
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild> <EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
<Title>Telegrator.Hosting.Web</Title> <Title>Telegrator.Hosting.Web</Title>
<Version>1.16.1</Version> <Version>1.16.3</Version>
<Authors>Rikitav Tim4ik</Authors> <Authors>Rikitav Tim4ik</Authors>
<Company>Rikitav Tim4ik</Company> <Company>Rikitav Tim4ik</Company>
<RepositoryUrl>https://github.com/Rikitav/Telegrator</RepositoryUrl> <RepositoryUrl>https://github.com/Rikitav/Telegrator</RepositoryUrl>
@@ -7,6 +7,7 @@ using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Telegram.Bot; using Telegram.Bot;
using Telegrator.Core; using Telegrator.Core;
using Telegrator.Hosting;
using Telegrator.Hosting.Web; using Telegrator.Hosting.Web;
using Telegrator.Mediation; using Telegrator.Mediation;
using Telegrator.Providers; using Telegrator.Providers;
@@ -12,7 +12,7 @@ namespace Telegrator.Hosting
/// <param name="client"></param> /// <param name="client"></param>
/// <param name="services"></param> /// <param name="services"></param>
/// <param name="configuration"></param> /// <param name="configuration"></param>
public class HostedTelegramBotInfo(ITelegramBotClient client, IServiceProvider services, IConfigurationManager configuration) : ITelegramBotInfo public class HostedTelegramBotInfo(ITelegramBotClient client, IServiceProvider services, IConfiguration configuration) : ITelegramBotInfo
{ {
/// <inheritdoc/> /// <inheritdoc/>
public User User { get; } = client.GetMe().Result; public User User { get; } = client.GetMe().Result;
@@ -25,6 +25,6 @@ namespace Telegrator.Hosting
/// <summary> /// <summary>
/// Provides access to configuration of this Hosted telegram bot /// Provides access to configuration of this Hosted telegram bot
/// </summary> /// </summary>
public IConfigurationManager Configuration { get; } = configuration; public IConfiguration Configuration { get; } = configuration;
} }
} }
@@ -1,29 +0,0 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Telegrator.Core;
namespace Telegrator.Hosting
{
/// <summary>
/// Interface for building Telegram bot hosts with dependency injection support.
/// Combines host application building capabilities with handler collection functionality.
/// </summary>
public interface ITelegramBotHostBuilder : ICollectingProvider
{
/// <summary>
/// Gets the set of key/value configuration properties.
/// </summary>
IConfigurationManager Configuration { get; }
/// <summary>
/// Gets a collection of logging providers for the application to compose. This is useful for adding new logging providers.
/// </summary>
ILoggingBuilder Logging { get; }
/// <summary>
/// Gets a collection of services for the application to compose. This is useful for adding user provided or framework provided services.
/// </summary>
IServiceCollection Services { get; }
}
}
@@ -1,5 +1,4 @@
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Telegrator.Core; using Telegrator.Core;
@@ -12,14 +11,13 @@ namespace Telegrator.Hosting
public class TelegramBotHost : IHost, ITelegratorBot public class TelegramBotHost : IHost, ITelegratorBot
{ {
private readonly IHost _innerHost; private readonly IHost _innerHost;
private readonly IServiceProvider _serviceProvider;
private readonly IUpdateRouter _updateRouter; private readonly IUpdateRouter _updateRouter;
private readonly ILogger<TelegramBotHost> _logger; private readonly ILogger<TelegramBotHost> _logger;
private bool _disposed; private bool _disposed;
/// <inheritdoc/> /// <inheritdoc/>
public IServiceProvider Services => _serviceProvider; public IServiceProvider Services => _innerHost.Services;
/// <inheritdoc/> /// <inheritdoc/>
public IUpdateRouter UpdateRouter => _updateRouter; public IUpdateRouter UpdateRouter => _updateRouter;
@@ -40,8 +38,6 @@ namespace Telegrator.Hosting
// Building proxy hoster // Building proxy hoster
_innerHost = hostApplicationBuilder.Build(); _innerHost = hostApplicationBuilder.Build();
_serviceProvider = _innerHost.Services;
_innerHost.UseTelegrator();
// Reruesting services for this host // Reruesting services for this host
_updateRouter = Services.GetRequiredService<IUpdateRouter>(); _updateRouter = Services.GetRequiredService<IUpdateRouter>();
@@ -56,9 +52,6 @@ namespace Telegrator.Hosting
{ {
HostApplicationBuilder innerBuilder = new HostApplicationBuilder(settings: null); HostApplicationBuilder innerBuilder = new HostApplicationBuilder(settings: null);
TelegramBotHostBuilder builder = new TelegramBotHostBuilder(innerBuilder, null); TelegramBotHostBuilder builder = new TelegramBotHostBuilder(innerBuilder, null);
builder.Services.AddTelegramBotHostDefaults();
builder.Services.AddTelegramReceiver();
return builder; return builder;
} }
@@ -70,9 +63,6 @@ namespace Telegrator.Hosting
{ {
HostApplicationBuilder innerBuilder = new HostApplicationBuilder(settings); HostApplicationBuilder innerBuilder = new HostApplicationBuilder(settings);
TelegramBotHostBuilder builder = new TelegramBotHostBuilder(innerBuilder, settings); TelegramBotHostBuilder builder = new TelegramBotHostBuilder(innerBuilder, settings);
builder.Services.AddTelegramBotHostDefaults();
builder.Services.AddTelegramReceiver();
return builder; return builder;
} }
@@ -1,7 +1,9 @@
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.Metrics;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Telegrator.Core; using Telegrator.Core;
using Telegrator.Providers; using Telegrator.Providers;
@@ -11,7 +13,7 @@ namespace Telegrator.Hosting
/// <summary> /// <summary>
/// Represents a hosted telegram bots and services builder that helps manage configuration, logging, lifetime, and more. /// Represents a hosted telegram bots and services builder that helps manage configuration, logging, lifetime, and more.
/// </summary> /// </summary>
public class TelegramBotHostBuilder : ICollectingProvider public class TelegramBotHostBuilder : IHostApplicationBuilder, ICollectingProvider
{ {
private readonly HostApplicationBuilder _innerBuilder; private readonly HostApplicationBuilder _innerBuilder;
private readonly HostApplicationBuilderSettings _settings; private readonly HostApplicationBuilderSettings _settings;
@@ -32,6 +34,12 @@ namespace Telegrator.Hosting
/// <inheritdoc/> /// <inheritdoc/>
public IHostEnvironment Environment => _innerBuilder.Environment; public IHostEnvironment Environment => _innerBuilder.Environment;
/// <inheritdoc/>
public IDictionary<object, object> Properties => ((IHostApplicationBuilder)_innerBuilder).Properties;
/// <inheritdoc/>
public IMetricsBuilder Metrics => _innerBuilder.Metrics;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="TelegramBotHostBuilder"/> class. /// Initializes a new instance of the <see cref="TelegramBotHostBuilder"/> class.
/// </summary> /// </summary>
@@ -42,8 +50,21 @@ namespace Telegrator.Hosting
_innerBuilder = hostApplicationBuilder ?? throw new ArgumentNullException(nameof(hostApplicationBuilder)); _innerBuilder = hostApplicationBuilder ?? throw new ArgumentNullException(nameof(hostApplicationBuilder));
_settings = settings ?? new HostApplicationBuilderSettings(); _settings = settings ?? new HostApplicationBuilderSettings();
_innerBuilder.AddTelegrator(); this.AddTelegrator();
_innerBuilder.Logging.ClearProviders(); }
/// <summary>
/// Initializes a new instance of the <see cref="TelegramBotHostBuilder"/> class.
/// </summary>
/// <param name="hostApplicationBuilder"></param>
/// <param name="options"></param>
/// <param name="settings"></param>
public TelegramBotHostBuilder(HostApplicationBuilder hostApplicationBuilder, TelegratorOptions? options, HostApplicationBuilderSettings? settings)
{
_innerBuilder = hostApplicationBuilder ?? throw new ArgumentNullException(nameof(hostApplicationBuilder));
_settings = settings ?? new HostApplicationBuilderSettings();
this.AddTelegrator(options, null);
} }
/// <summary> /// <summary>
@@ -52,13 +73,27 @@ namespace Telegrator.Hosting
/// <param name="hostApplicationBuilder"></param> /// <param name="hostApplicationBuilder"></param>
/// <param name="handlers"></param> /// <param name="handlers"></param>
/// <param name="settings"></param> /// <param name="settings"></param>
public TelegramBotHostBuilder(HostApplicationBuilder hostApplicationBuilder, IHandlersCollection handlers, HostApplicationBuilderSettings? settings = null) public TelegramBotHostBuilder(HostApplicationBuilder hostApplicationBuilder, IHandlersCollection handlers, HostApplicationBuilderSettings? settings)
{ {
_innerBuilder = hostApplicationBuilder ?? throw new ArgumentNullException(nameof(hostApplicationBuilder)); _innerBuilder = hostApplicationBuilder ?? throw new ArgumentNullException(nameof(hostApplicationBuilder));
_settings = settings ?? new HostApplicationBuilderSettings(); _settings = settings ?? new HostApplicationBuilderSettings();
_innerBuilder.AddTelegrator(null, handlers); this.AddTelegrator(null, handlers);
_innerBuilder.Logging.ClearProviders(); }
/// <summary>
/// Initializes a new instance of the <see cref="TelegramBotHostBuilder"/> class.
/// </summary>
/// <param name="hostApplicationBuilder"></param>
/// <param name="handlers"></param>
/// <param name="options"></param>
/// <param name="settings"></param>
public TelegramBotHostBuilder(HostApplicationBuilder hostApplicationBuilder, IHandlersCollection handlers, TelegratorOptions? options, HostApplicationBuilderSettings? settings)
{
_innerBuilder = hostApplicationBuilder ?? throw new ArgumentNullException(nameof(hostApplicationBuilder));
_settings = settings ?? new HostApplicationBuilderSettings();
this.AddTelegrator(options, handlers);
} }
/// <summary> /// <summary>
@@ -71,5 +106,11 @@ namespace Telegrator.Hosting
host.UseTelegrator(); host.UseTelegrator();
return host; return host;
} }
/// <inheritdoc/>
public void ConfigureContainer<TContainerBuilder>(IServiceProviderFactory<TContainerBuilder> factory, Action<TContainerBuilder>? configure = null) where TContainerBuilder : notnull
{
this.ConfigureContainer(factory, configure);
}
} }
} }
@@ -1,13 +0,0 @@
using Microsoft.Extensions.Options;
using Telegrator.Core;
using Telegrator.Mediation;
namespace Telegrator.Polling
{
/// <inheritdoc/>
public class HostUpdateHandlersPool(IUpdateRouter router, IOptions<TelegratorOptions> options)
: UpdateHandlersPool(router, options.Value, options.Value.GlobalCancellationToken)
{
}
}
@@ -21,9 +21,8 @@ namespace Telegrator.Polling
IHandlersProvider handlersProvider, IHandlersProvider handlersProvider,
IAwaitingProvider awaitingProvider, IAwaitingProvider awaitingProvider,
IOptions<TelegratorOptions> options, IOptions<TelegratorOptions> options,
IUpdateHandlersPool handlersPool,
ITelegramBotInfo botInfo, ITelegramBotInfo botInfo,
ILogger<HostUpdateRouter> logger) : base(handlersProvider, awaitingProvider, options.Value, handlersPool, botInfo) ILogger<HostUpdateRouter> logger) : base(handlersProvider, awaitingProvider, options.Value, botInfo)
{ {
Logger = logger; Logger = logger;
ExceptionHandler = new DefaultRouterExceptionHandler(HandleException); ExceptionHandler = new DefaultRouterExceptionHandler(HandleException);
@@ -15,7 +15,7 @@
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild> <EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
<Title>Telegrator.Hosting</Title> <Title>Telegrator.Hosting</Title>
<Version>1.16.1</Version> <Version>1.16.3</Version>
<Authors>Rikitav Tim4ik</Authors> <Authors>Rikitav Tim4ik</Authors>
<Company>Rikitav Tim4ik</Company> <Company>Rikitav Tim4ik</Company>
<RepositoryUrl>https://github.com/Rikitav/Telegrator</RepositoryUrl> <RepositoryUrl>https://github.com/Rikitav/Telegrator</RepositoryUrl>
@@ -120,7 +120,6 @@ public static class ServicesCollectionExtensions
public static IServiceCollection AddTelegramBotHostDefaults(this IServiceCollection services) public static IServiceCollection AddTelegramBotHostDefaults(this IServiceCollection services)
{ {
services.AddLogging(builder => builder.AddConsole().AddDebug()); services.AddLogging(builder => builder.AddConsole().AddDebug());
services.AddSingleton<IUpdateHandlersPool, HostUpdateHandlersPool>();
services.AddSingleton<IAwaitingProvider, HostAwaitingProvider>(); services.AddSingleton<IAwaitingProvider, HostAwaitingProvider>();
services.AddSingleton<IHandlersProvider, HostHandlersProvider>(); services.AddSingleton<IHandlersProvider, HostHandlersProvider>();
services.AddSingleton<IUpdateRouter, HostUpdateRouter>(); services.AddSingleton<IUpdateRouter, HostUpdateRouter>();
@@ -114,7 +114,7 @@ namespace Telegrator.Core.Descriptors
/// <param name="result">The execution result.</param> /// <param name="result">The execution result.</param>
public void ReportResult(Result? result) public void ReportResult(Result? result)
{ {
if (result != null) if (Result != null)
throw new InvalidOperationException("Result already reported"); throw new InvalidOperationException("Result already reported");
Result = result; Result = result;
-17
View File
@@ -58,23 +58,6 @@ namespace Telegrator.Mediation
_botInfo = botInfo; _botInfo = botInfo;
} }
/// <summary>
/// Initializes a new instance of the <see cref="UpdateRouter"/> class with a custom handlers pool.
/// </summary>
/// <param name="handlersProvider">The provider for regular handlers.</param>
/// <param name="awaitingProvider">The provider for awaiting handlers.</param>
/// <param name="options">The bot configuration options.</param>
/// <param name="handlersPool">The custom handlers pool to use.</param>
/// <param name="botInfo"></param>
public UpdateRouter(IHandlersProvider handlersProvider, IAwaitingProvider awaitingProvider, TelegratorOptions options, IUpdateHandlersPool handlersPool, ITelegramBotInfo botInfo)
{
_options = options;
_handlersProvider = handlersProvider;
_awaitingProvider = awaitingProvider;
_HandlersPool = handlersPool;
_botInfo = botInfo;
}
/// <summary> /// <summary>
/// Handles errors that occur during update processing. /// Handles errors that occur during update processing.
/// </summary> /// </summary>
+1 -1
View File
@@ -14,7 +14,7 @@
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild> <EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
<Title>Telegrator : Telegram.Bot mediator framework</Title> <Title>Telegrator : Telegram.Bot mediator framework</Title>
<Version>1.16.1</Version> <Version>1.16.3</Version>
<Authors>Rikitav Tim4ik</Authors> <Authors>Rikitav Tim4ik</Authors>
<Company>Rikitav Tim4ik</Company> <Company>Rikitav Tim4ik</Company>
<RepositoryUrl>https://github.com/Rikitav/Telegrator</RepositoryUrl> <RepositoryUrl>https://github.com/Rikitav/Telegrator</RepositoryUrl>