* Added WideBotOptions
* Added ConfigureWideBot method * Refactored `AddWideTelegrator` method * Added `dbConnectionFactory`
This commit is contained in:
@@ -4,41 +4,12 @@
|
|||||||
<name>Telegrator.Hosting.Web</name>
|
<name>Telegrator.Hosting.Web</name>
|
||||||
</assembly>
|
</assembly>
|
||||||
<members>
|
<members>
|
||||||
<member name="T:Telegrator.Hosting.Web.WebhookerOptions">
|
|
||||||
<summary>
|
|
||||||
Configuration options for Telegram bot behavior and execution settings.
|
|
||||||
Controls various aspects of bot operation including concurrency, routing, webhook receiving, and execution policies.
|
|
||||||
</summary>
|
|
||||||
</member>
|
|
||||||
<member name="P:Telegrator.Hosting.Web.WebhookerOptions.WebhookUri">
|
|
||||||
<summary>
|
|
||||||
Gets or sets HTTPS URL to send updates to. Use an empty string to remove webhook integration
|
|
||||||
</summary>
|
|
||||||
</member>
|
|
||||||
<member name="P:Telegrator.Hosting.Web.WebhookerOptions.SecretToken">
|
|
||||||
<summary>
|
|
||||||
A secret token to be sent in a header “X-Telegram-Bot-Api-Secret-Token” in every webhook request, 1-256 characters.
|
|
||||||
Only characters A-Z, a-z, 0-9, _ and - are allowed.
|
|
||||||
The header is useful to ensure that the request comes from a webhook set by you.
|
|
||||||
</summary>
|
|
||||||
</member>
|
|
||||||
<member name="P:Telegrator.Hosting.Web.WebhookerOptions.MaxConnections">
|
|
||||||
<summary>
|
|
||||||
The maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100. Defaults to 40.
|
|
||||||
Use lower values to limit the load on your bot's server, and higher values to increase your bot's throughput.
|
|
||||||
</summary>
|
|
||||||
</member>
|
|
||||||
<member name="P:Telegrator.Hosting.Web.WebhookerOptions.DropPendingUpdates">
|
|
||||||
<summary>
|
|
||||||
Pass true to drop all pending updates
|
|
||||||
</summary>
|
|
||||||
</member>
|
|
||||||
<member name="T:Telegrator.Mediation.HostedUpdateWebhooker">
|
<member name="T:Telegrator.Mediation.HostedUpdateWebhooker">
|
||||||
<summary>
|
<summary>
|
||||||
Service for receiving updates for Hosted telegram bots via Webhooks and queuing them to router
|
Service for receiving updates for Hosted telegram bots via Webhooks and queuing them to router
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Telegrator.Mediation.HostedUpdateWebhooker.#ctor(Telegram.Bot.ITelegramBotClient,Telegrator.Core.IUpdateRouter,Microsoft.Extensions.Options.IOptions{Telegrator.Hosting.Web.WebhookerOptions})">
|
<member name="M:Telegrator.Mediation.HostedUpdateWebhooker.#ctor(Telegram.Bot.ITelegramBotClient,Telegrator.Core.IUpdateRouter,Microsoft.Extensions.Options.IOptions{Telegrator.WebhookerOptions})">
|
||||||
<summary>
|
<summary>
|
||||||
Initiallizes new instance of <see cref="T:Telegrator.Mediation.HostedUpdateWebhooker"/>
|
Initiallizes new instance of <see cref="T:Telegrator.Mediation.HostedUpdateWebhooker"/>
|
||||||
</summary>
|
</summary>
|
||||||
@@ -95,7 +66,7 @@
|
|||||||
Provides method to configure Telegram Bot WebHost
|
Provides method to configure Telegram Bot WebHost
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Telegrator.WebServicesCollectionExtensions.ConfigureWebhooker(Microsoft.Extensions.DependencyInjection.IServiceCollection,Telegrator.Hosting.Web.WebhookerOptions)">
|
<member name="M:Telegrator.WebServicesCollectionExtensions.ConfigureWebhooker(Microsoft.Extensions.DependencyInjection.IServiceCollection,Telegrator.WebhookerOptions)">
|
||||||
<summary>
|
<summary>
|
||||||
Adds WebhookerOptions to services
|
Adds WebhookerOptions to services
|
||||||
</summary>
|
</summary>
|
||||||
@@ -138,5 +109,34 @@
|
|||||||
<param name="services"></param>
|
<param name="services"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="T:Telegrator.WebhookerOptions">
|
||||||
|
<summary>
|
||||||
|
Configuration options for Telegram bot behavior and execution settings.
|
||||||
|
Controls various aspects of bot operation including concurrency, routing, webhook receiving, and execution policies.
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:Telegrator.WebhookerOptions.WebhookUri">
|
||||||
|
<summary>
|
||||||
|
Gets or sets HTTPS URL to send updates to. Use an empty string to remove webhook integration
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:Telegrator.WebhookerOptions.SecretToken">
|
||||||
|
<summary>
|
||||||
|
A secret token to be sent in a header “X-Telegram-Bot-Api-Secret-Token” in every webhook request, 1-256 characters.
|
||||||
|
Only characters A-Z, a-z, 0-9, _ and - are allowed.
|
||||||
|
The header is useful to ensure that the request comes from a webhook set by you.
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:Telegrator.WebhookerOptions.MaxConnections">
|
||||||
|
<summary>
|
||||||
|
The maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100. Defaults to 40.
|
||||||
|
Use lower values to limit the load on your bot's server, and higher values to increase your bot's throughput.
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:Telegrator.WebhookerOptions.DropPendingUpdates">
|
||||||
|
<summary>
|
||||||
|
Pass true to drop all pending updates
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
</members>
|
</members>
|
||||||
</doc>
|
</doc>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
<param name="updateRouter"></param>
|
<param name="updateRouter"></param>
|
||||||
<param name="options"></param>
|
<param name="options"></param>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Telegrator.Mediation.HostedWideBotUpdateReceiver.#ctor(Microsoft.Extensions.Logging.ILogger{Telegrator.Mediation.HostedWideBotUpdateReceiver},Telegram.Bot.ITelegramBotClient,Telegrator.Core.IUpdateRouter,Microsoft.Extensions.Options.IOptions{Telegram.Bot.Polling.ReceiverOptions})">
|
<member name="M:Telegrator.Mediation.HostedWideBotUpdateReceiver.#ctor(Microsoft.Extensions.Logging.ILogger{Telegrator.Mediation.HostedWideBotUpdateReceiver},Telegram.Bot.ITelegramBotClient,Telegrator.Core.IUpdateRouter,Microsoft.Extensions.Options.IOptions{Telegrator.WideBotOptions})">
|
||||||
<summary>
|
<summary>
|
||||||
Service for receiving updates for Hosted wide telegram bots and queuing them to router
|
Service for receiving updates for Hosted wide telegram bots and queuing them to router
|
||||||
</summary>
|
</summary>
|
||||||
@@ -119,17 +119,17 @@
|
|||||||
Provides extension methods for <see cref="T:Microsoft.Extensions.Hosting.IHostApplicationBuilder"/> to configure Telegrator.
|
Provides extension methods for <see cref="T:Microsoft.Extensions.Hosting.IHostApplicationBuilder"/> to configure Telegrator.
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Telegrator.WideHostBuilderExtensions.AddWideTelegrator(Microsoft.Extensions.Hosting.IHostApplicationBuilder,Telegrator.TelegratorOptions,Telegrator.Core.IHandlersCollection,System.Action{Telegrator.Hosting.ITelegramBotHostBuilder})">
|
<member name="M:Telegrator.WideHostBuilderExtensions.AddWideTelegrator(Microsoft.Extensions.Hosting.IHostApplicationBuilder,System.Func{System.IServiceProvider,System.Data.Common.DbConnection},System.Action{Telegrator.Hosting.ITelegramBotHostBuilder},Telegrator.TelegratorOptions,Telegrator.Core.IHandlersCollection)">
|
||||||
<summary>
|
<summary>
|
||||||
Replaces TelegramBotHostBuilder. Configures DI, options, and handlers.
|
Replaces TelegramBotHostBuilder. Configures DI, options, and handlers.
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Telegrator.WideHostBuilderExtensions.AddWideTelegrator(Microsoft.Extensions.Hosting.IHostApplicationBuilder,Telegrator.TelegratorOptions,Telegrator.Core.IHandlersCollection)">
|
<member name="M:Telegrator.WideHostBuilderExtensions.AddWideTelegrator(Microsoft.Extensions.Hosting.IHostApplicationBuilder,System.Func{System.IServiceProvider,System.Data.Common.DbConnection},Telegrator.TelegratorOptions,Telegrator.Core.IHandlersCollection)">
|
||||||
<summary>
|
<summary>
|
||||||
Replaces TelegramBotHostBuilder. Configures DI, options, and handlers.
|
Replaces TelegramBotHostBuilder. Configures DI, options, and handlers.
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Telegrator.WideHostBuilderExtensions.AddWideTelegratorInternal(Microsoft.Extensions.DependencyInjection.IServiceCollection,Microsoft.Extensions.Configuration.IConfiguration,System.Collections.Generic.IDictionary{System.Object,System.Object},Telegrator.Core.IHandlersCollection@,Telegrator.TelegratorOptions)">
|
<member name="M:Telegrator.WideHostBuilderExtensions.AddWideTelegratorInternal(Microsoft.Extensions.DependencyInjection.IServiceCollection,Microsoft.Extensions.Configuration.IConfiguration,System.Collections.Generic.IDictionary{System.Object,System.Object},System.Func{System.IServiceProvider,System.Data.Common.DbConnection},Telegrator.Core.IHandlersCollection@,Telegrator.TelegratorOptions)">
|
||||||
<summary>
|
<summary>
|
||||||
Replaces TelegramBotHostBuilder. Configures DI, options, and handlers.
|
Replaces TelegramBotHostBuilder. Configures DI, options, and handlers.
|
||||||
</summary>
|
</summary>
|
||||||
@@ -148,6 +148,14 @@
|
|||||||
<param name="options"></param>
|
<param name="options"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:Telegrator.WideBotServiceCollectionExtensions.ConfigureWideBot(Microsoft.Extensions.DependencyInjection.IServiceCollection,Telegrator.WideBotOptions)">
|
||||||
|
<summary>
|
||||||
|
Adds WTelegramBotClientOptions to services
|
||||||
|
</summary>
|
||||||
|
<param name="services"></param>
|
||||||
|
<param name="options"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="M:Telegrator.WideBotServiceCollectionExtensions.AddMTProtoUpdateReceiver(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Boolean)">
|
<member name="M:Telegrator.WideBotServiceCollectionExtensions.AddMTProtoUpdateReceiver(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Boolean)">
|
||||||
<summary>
|
<summary>
|
||||||
Adds WTelegramBotClient
|
Adds WTelegramBotClient
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<doc>
|
||||||
|
<assembly>
|
||||||
|
<name>Telegrator.Localized</name>
|
||||||
|
</assembly>
|
||||||
|
<members>
|
||||||
|
</members>
|
||||||
|
</doc>
|
||||||
@@ -13,6 +13,9 @@
|
|||||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||||
<EnableNETAnalyzers>True</EnableNETAnalyzers>
|
<EnableNETAnalyzers>True</EnableNETAnalyzers>
|
||||||
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
|
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
|
||||||
|
<IncludeSymbols>True</IncludeSymbols>
|
||||||
|
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||||
|
<SignAssembly>False</SignAssembly>
|
||||||
|
|
||||||
<Title>Telegrator.RedisStateStorage</Title>
|
<Title>Telegrator.RedisStateStorage</Title>
|
||||||
<Version>1.16.6</Version>
|
<Version>1.16.6</Version>
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ using System.Text.Json;
|
|||||||
using Telegram.Bot;
|
using Telegram.Bot;
|
||||||
using Telegram.Bot.Types;
|
using Telegram.Bot.Types;
|
||||||
using Telegrator.Core;
|
using Telegrator.Core;
|
||||||
using Telegrator.Hosting.Web;
|
|
||||||
|
|
||||||
namespace Telegrator.Mediation;
|
namespace Telegrator.Mediation;
|
||||||
|
|
||||||
|
|||||||
@@ -13,9 +13,12 @@
|
|||||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||||
<EnableNETAnalyzers>True</EnableNETAnalyzers>
|
<EnableNETAnalyzers>True</EnableNETAnalyzers>
|
||||||
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
|
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
|
||||||
|
<IncludeSymbols>True</IncludeSymbols>
|
||||||
|
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||||
|
<SignAssembly>False</SignAssembly>
|
||||||
|
|
||||||
<Title>Telegrator.Hosting.Web</Title>
|
<Title>Telegrator.Hosting.Web</Title>
|
||||||
<Version>1.17.0</Version>
|
<Version>1.17.1</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>
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ using System.Diagnostics.CodeAnalysis;
|
|||||||
using Telegram.Bot;
|
using Telegram.Bot;
|
||||||
using Telegrator.Core;
|
using Telegrator.Core;
|
||||||
using Telegrator.Hosting;
|
using Telegrator.Hosting;
|
||||||
using Telegrator.Hosting.Web;
|
|
||||||
using Telegrator.Mediation;
|
using Telegrator.Mediation;
|
||||||
using Telegrator.Providers;
|
using Telegrator.Providers;
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
|
||||||
namespace Telegrator.Hosting.Web;
|
namespace Telegrator;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Configuration options for Telegram bot behavior and execution settings.
|
/// Configuration options for Telegram bot behavior and execution settings.
|
||||||
@@ -14,7 +14,7 @@ namespace Telegrator.Mediation;
|
|||||||
/// <param name="botClient"></param>
|
/// <param name="botClient"></param>
|
||||||
/// <param name="updateRouter"></param>
|
/// <param name="updateRouter"></param>
|
||||||
/// <param name="options"></param>
|
/// <param name="options"></param>
|
||||||
public class HostedWideBotUpdateReceiver(ILogger<HostedWideBotUpdateReceiver> logger, ITelegramBotClient botClient, IUpdateRouter updateRouter, IOptions<ReceiverOptions>? options) : BackgroundService
|
public class HostedWideBotUpdateReceiver(ILogger<HostedWideBotUpdateReceiver> logger, ITelegramBotClient botClient, IUpdateRouter updateRouter, IOptions<WideBotOptions>? options) : BackgroundService
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||||
|
|||||||
@@ -13,9 +13,12 @@
|
|||||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||||
<EnableNETAnalyzers>True</EnableNETAnalyzers>
|
<EnableNETAnalyzers>True</EnableNETAnalyzers>
|
||||||
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
|
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
|
||||||
|
<IncludeSymbols>True</IncludeSymbols>
|
||||||
|
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||||
|
<SignAssembly>False</SignAssembly>
|
||||||
|
|
||||||
<Title>Telegrator.Hosting.WideBot</Title>
|
<Title>Telegrator.Hosting.WideBot</Title>
|
||||||
<Version>1.17.0</Version>
|
<Version>1.17.1</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>
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ using Telegrator.Providers;
|
|||||||
|
|
||||||
using WUpdate = WTelegram.Types.Update;
|
using WUpdate = WTelegram.Types.Update;
|
||||||
using TLUpdate = TL.Update;
|
using TLUpdate = TL.Update;
|
||||||
|
using System.Data.Common;
|
||||||
|
|
||||||
namespace Telegrator;
|
namespace Telegrator;
|
||||||
|
|
||||||
@@ -92,9 +93,9 @@ public static class WideHostBuilderExtensions
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Replaces TelegramBotHostBuilder. Configures DI, options, and handlers.
|
/// Replaces TelegramBotHostBuilder. Configures DI, options, and handlers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static IHostApplicationBuilder AddWideTelegrator(this IHostApplicationBuilder builder, TelegratorOptions? options = null, IHandlersCollection? handlers = null, Action<ITelegramBotHostBuilder>? action = null)
|
public static IHostApplicationBuilder AddWideTelegrator(this IHostApplicationBuilder builder, Func<IServiceProvider, DbConnection> dbConnectionFactory, Action<ITelegramBotHostBuilder>? action = null, TelegratorOptions? options = null, IHandlersCollection? handlers = null)
|
||||||
{
|
{
|
||||||
AddWideTelegratorInternal(builder.Services, builder.Configuration, builder.Properties, ref handlers, options);
|
AddWideTelegratorInternal(builder.Services, builder.Configuration, builder.Properties, dbConnectionFactory, ref handlers, options);
|
||||||
action?.Invoke(new TelegramBotHostBuilder(builder, handlers));
|
action?.Invoke(new TelegramBotHostBuilder(builder, handlers));
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
@@ -102,16 +103,16 @@ public static class WideHostBuilderExtensions
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Replaces TelegramBotHostBuilder. Configures DI, options, and handlers.
|
/// Replaces TelegramBotHostBuilder. Configures DI, options, and handlers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static IHostApplicationBuilder AddWideTelegrator(this IHostApplicationBuilder builder, TelegratorOptions? options = null, IHandlersCollection? handlers = null)
|
public static IHostApplicationBuilder AddWideTelegrator(this IHostApplicationBuilder builder, Func<IServiceProvider, DbConnection> dbConnectionFactory, TelegratorOptions? options = null, IHandlersCollection? handlers = null)
|
||||||
{
|
{
|
||||||
AddWideTelegratorInternal(builder.Services, builder.Configuration, builder.Properties, ref handlers, options);
|
AddWideTelegratorInternal(builder.Services, builder.Configuration, builder.Properties, dbConnectionFactory, ref handlers, options);
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Replaces TelegramBotHostBuilder. Configures DI, options, and handlers.
|
/// Replaces TelegramBotHostBuilder. Configures DI, options, and handlers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static void AddWideTelegratorInternal(IServiceCollection services, IConfiguration configuration, IDictionary<object, object> properties, [NotNull] ref IHandlersCollection? handlers, TelegratorOptions? options = null)
|
internal static void AddWideTelegratorInternal(IServiceCollection services, IConfiguration configuration, IDictionary<object, object> properties, Func<IServiceProvider, DbConnection> dbConnectionFactory, [NotNull] ref IHandlersCollection? handlers, TelegratorOptions? options = null)
|
||||||
{
|
{
|
||||||
if (services.Any(srvc => srvc.ServiceType == typeof(HostedUpdateReceiver)))
|
if (services.Any(srvc => srvc.ServiceType == typeof(HostedUpdateReceiver)))
|
||||||
throw new InvalidOperationException("`HostedUpdateReceiver` found in services. WideHost extension is not compatible with default long-polling receiver. Please, remove `AddTelegrator` invocation from your Host configuration.");
|
throw new InvalidOperationException("`HostedUpdateReceiver` found in services. WideHost extension is not compatible with default long-polling receiver. Please, remove `AddTelegrator` invocation from your Host configuration.");
|
||||||
@@ -147,16 +148,32 @@ public static class WideHostBuilderExtensions
|
|||||||
|
|
||||||
if (!services.Any(srvc => srvc.ServiceType == typeof(IOptions<WTelegramBotClientOptions>)))
|
if (!services.Any(srvc => srvc.ServiceType == typeof(IOptions<WTelegramBotClientOptions>)))
|
||||||
{
|
{
|
||||||
// For now, there's no way to configure this from IConfiguration, use `ConfigureWideTelegram` instead
|
WideBotOptions? wideBotOptions = configuration.GetSection(nameof(WideBotOptions)).Get<WideBotOptions>();
|
||||||
throw new MissingMemberException("No options of type 'WTelegramBotClientOptions' was registered. This configuration is runtime required! Use `ConfigureWideTelegram` to register options.");
|
if (wideBotOptions == null)
|
||||||
|
throw new MissingMemberException("Auto configuration disabled, yet no options of type 'WideBotOptions' was registered. This configuration is runtime required!");
|
||||||
|
|
||||||
/*
|
services.AddSingleton(provider =>
|
||||||
services.AddSingleton(Options.Create(new WTelegramBotClientOptions(options.Token, options.BaseUrl, options.UseTestEnvironment)
|
{
|
||||||
|
IHostApplicationLifetime lifetime = provider.GetRequiredService<IHostApplicationLifetime>();
|
||||||
|
|
||||||
|
DbConnection dbConnection = dbConnectionFactory.Invoke(provider);
|
||||||
|
lifetime.ApplicationStopping.Register(() => dbConnection.Dispose());
|
||||||
|
|
||||||
|
WTelegramBotClientOptions wideOptions = new WTelegramBotClientOptions(
|
||||||
|
token: options.Token,
|
||||||
|
apiId: wideBotOptions.ApiId,
|
||||||
|
apiHash: wideBotOptions.ApiHash,
|
||||||
|
dbConnection: dbConnection,
|
||||||
|
sqlCommands: wideBotOptions.SqlCommands,
|
||||||
|
useTestEnvironment: options.UseTestEnvironment,
|
||||||
|
mtproxy: wideBotOptions.MTProxy)
|
||||||
{
|
{
|
||||||
RetryCount = options.RetryCount,
|
RetryCount = options.RetryCount,
|
||||||
RetryThreshold = options.RetryThreshold
|
RetryThreshold = options.RetryThreshold
|
||||||
}));
|
};
|
||||||
*/
|
|
||||||
|
return Options.Create(wideOptions);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
services.AddTelegramBotHostDefaults();
|
services.AddTelegramBotHostDefaults();
|
||||||
@@ -183,6 +200,19 @@ public static class WideBotServiceCollectionExtensions
|
|||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds WTelegramBotClientOptions to services
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="services"></param>
|
||||||
|
/// <param name="options"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static IServiceCollection ConfigureWideBot(this IServiceCollection services, WideBotOptions options)
|
||||||
|
{
|
||||||
|
services.RemoveAll<IOptions<WideBotOptions>>();
|
||||||
|
services.AddSingleton(Options.Create(options));
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds WTelegramBotClient
|
/// Adds WTelegramBotClient
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using WTelegram;
|
||||||
|
|
||||||
|
namespace Telegrator;
|
||||||
|
|
||||||
|
public class WideBotOptions
|
||||||
|
{
|
||||||
|
public required int ApiId { get; set; }
|
||||||
|
|
||||||
|
public required string ApiHash { get; set; }
|
||||||
|
|
||||||
|
public string? MTProxy { get; set; }
|
||||||
|
|
||||||
|
public bool DropPendingUpdates { get; set; }
|
||||||
|
|
||||||
|
public SqlCommands SqlCommands { get; set; } = WTelegram.SqlCommands.Detect;
|
||||||
|
}
|
||||||
@@ -13,9 +13,12 @@
|
|||||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||||
<EnableNETAnalyzers>True</EnableNETAnalyzers>
|
<EnableNETAnalyzers>True</EnableNETAnalyzers>
|
||||||
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
|
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
|
||||||
|
<IncludeSymbols>True</IncludeSymbols>
|
||||||
|
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||||
|
<SignAssembly>False</SignAssembly>
|
||||||
|
|
||||||
<Title>Telegrator.Hosting</Title>
|
<Title>Telegrator.Hosting</Title>
|
||||||
<Version>1.17.0</Version>
|
<Version>1.17.1</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>
|
||||||
|
|||||||
@@ -2,7 +2,31 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.1</TargetFramework>
|
<TargetFramework>netstandard2.1</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
|
<RootNamespace>Telegrator</RootNamespace>
|
||||||
|
<BaseOutputPath>..\..\bin</BaseOutputPath>
|
||||||
|
<DocumentationFile>..\..\docs\$(AssemblyName).xml</DocumentationFile>
|
||||||
|
|
||||||
|
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
|
||||||
|
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||||
|
<EnableNETAnalyzers>True</EnableNETAnalyzers>
|
||||||
|
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
|
||||||
|
<IncludeSymbols>True</IncludeSymbols>
|
||||||
|
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||||
|
<SignAssembly>False</SignAssembly>
|
||||||
|
|
||||||
|
<Title>Telegrator.Localized</Title>
|
||||||
|
<Version>1.17.1</Version>
|
||||||
|
<Authors>Rikitav Tim4ik</Authors>
|
||||||
|
<Company>Rikitav Tim4ik</Company>
|
||||||
|
<RepositoryUrl>https://github.com/Rikitav/Telegrator</RepositoryUrl>
|
||||||
|
<PackageTags>telegram;bot;mediator;attributes;aspect;hosting;host;framework;easy;simple;handlers</PackageTags>
|
||||||
|
|
||||||
|
<PackageIcon>telegrator_nuget.png</PackageIcon>
|
||||||
|
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||||
|
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -13,4 +37,10 @@
|
|||||||
<ProjectReference Include="..\Telegrator\Telegrator.csproj" />
|
<ProjectReference Include="..\Telegrator\Telegrator.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include=".\README.md" Pack="True" PackagePath="\" />
|
||||||
|
<None Include="..\..\LICENSE" Pack="True" PackagePath="\" />
|
||||||
|
<None Include="..\..\resources\telegrator_nuget.png" Pack="True" PackagePath="\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -12,9 +12,12 @@
|
|||||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||||
<EnableNETAnalyzers>True</EnableNETAnalyzers>
|
<EnableNETAnalyzers>True</EnableNETAnalyzers>
|
||||||
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
|
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
|
||||||
|
<IncludeSymbols>True</IncludeSymbols>
|
||||||
|
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||||
|
<SignAssembly>False</SignAssembly>
|
||||||
|
|
||||||
<Title>Telegrator : Telegram.Bot mediator framework</Title>
|
<Title>Telegrator : Telegram.Bot mediator framework</Title>
|
||||||
<Version>1.17.0</Version>
|
<Version>1.17.1</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>
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.Data.Sqlite;
|
using Microsoft.Data.Sqlite;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using System.Data.Common;
|
using Telegram.Bot.Polling;
|
||||||
using Telegram.Bot;
|
|
||||||
|
|
||||||
namespace Telegrator.Tests;
|
namespace Telegrator.Tests;
|
||||||
|
|
||||||
@@ -16,6 +15,12 @@ internal static class Program
|
|||||||
ApplicationName = "Host example",
|
ApplicationName = "Host example",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
builder.Services.ConfigureReceiver(new ReceiverOptions()
|
||||||
|
{
|
||||||
|
DropPendingUpdates = true,
|
||||||
|
Limit = 100
|
||||||
|
});
|
||||||
|
|
||||||
builder.AddTelegrator(action: builder => builder.Handlers
|
builder.AddTelegrator(action: builder => builder.Handlers
|
||||||
.CollectHandlersAssemblyWide());
|
.CollectHandlersAssemblyWide());
|
||||||
|
|
||||||
@@ -32,12 +37,16 @@ internal static class Program
|
|||||||
ApplicationName = "WBot example",
|
ApplicationName = "WBot example",
|
||||||
});
|
});
|
||||||
|
|
||||||
using DbConnection connection = new SqliteConnection("Data Source=wtgb.db");
|
builder.Services.ConfigureWideBot(new WideBotOptions()
|
||||||
builder.Services.ConfigureWideTelegram(
|
{
|
||||||
new WTelegramBotClientOptions(token: "BOT_TOKEN", apiId: 123, apiHash: "API_HASH", dbConnection: connection));
|
ApiId = 123,
|
||||||
|
ApiHash = "API_HASH",
|
||||||
|
DropPendingUpdates = true,
|
||||||
|
});
|
||||||
|
|
||||||
builder.AddWideTelegrator(action: builder => builder.Handlers
|
builder.AddWideTelegrator(
|
||||||
.CollectHandlersAssemblyWide());
|
dbConnectionFactory: provider => new SqliteConnection($"Data Source={Environment.ExpandEnvironmentVariables("%AppData%\\Telegrator\\%wtgb.db")}"),
|
||||||
|
action: builder => builder.Handlers.CollectHandlersAssemblyWide());
|
||||||
|
|
||||||
builder.Build()
|
builder.Build()
|
||||||
.UseWideTelegrator()
|
.UseWideTelegrator()
|
||||||
@@ -52,6 +61,13 @@ internal static class Program
|
|||||||
ApplicationName = "WebApplication example",
|
ApplicationName = "WebApplication example",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
builder.Services.ConfigureWebhooker(new WebhookerOptions()
|
||||||
|
{
|
||||||
|
WebhookUri = "https://medic-gaming.com/",
|
||||||
|
DropPendingUpdates = true,
|
||||||
|
SecretToken = "MEDIC_GAMING"
|
||||||
|
});
|
||||||
|
|
||||||
builder.AddTelegratorWeb(action: builder => builder.Handlers
|
builder.AddTelegratorWeb(action: builder => builder.Handlers
|
||||||
.CollectHandlersAssemblyWide());
|
.CollectHandlersAssemblyWide());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user