* Added WideBotOptions

* Added ConfigureWideBot method
* Refactored `AddWideTelegrator` method
* Added `dbConnectionFactory`
This commit is contained in:
gutii
2026-05-01 20:48:32 +04:00
parent 6453e42d06
commit 39f9abd9de
17 changed files with 184 additions and 63 deletions
+23 -7
View File
@@ -1,8 +1,7 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Data.Sqlite;
using Microsoft.Extensions.Hosting;
using System.Data.Common;
using Telegram.Bot;
using Telegram.Bot.Polling;
namespace Telegrator.Tests;
@@ -16,6 +15,12 @@ internal static class Program
ApplicationName = "Host example",
});
builder.Services.ConfigureReceiver(new ReceiverOptions()
{
DropPendingUpdates = true,
Limit = 100
});
builder.AddTelegrator(action: builder => builder.Handlers
.CollectHandlersAssemblyWide());
@@ -32,12 +37,16 @@ internal static class Program
ApplicationName = "WBot example",
});
using DbConnection connection = new SqliteConnection("Data Source=wtgb.db");
builder.Services.ConfigureWideTelegram(
new WTelegramBotClientOptions(token: "BOT_TOKEN", apiId: 123, apiHash: "API_HASH", dbConnection: connection));
builder.Services.ConfigureWideBot(new WideBotOptions()
{
ApiId = 123,
ApiHash = "API_HASH",
DropPendingUpdates = true,
});
builder.AddWideTelegrator(action: builder => builder.Handlers
.CollectHandlersAssemblyWide());
builder.AddWideTelegrator(
dbConnectionFactory: provider => new SqliteConnection($"Data Source={Environment.ExpandEnvironmentVariables("%AppData%\\Telegrator\\%wtgb.db")}"),
action: builder => builder.Handlers.CollectHandlersAssemblyWide());
builder.Build()
.UseWideTelegrator()
@@ -52,6 +61,13 @@ internal static class Program
ApplicationName = "WebApplication example",
});
builder.Services.ConfigureWebhooker(new WebhookerOptions()
{
WebhookUri = "https://medic-gaming.com/",
DropPendingUpdates = true,
SecretToken = "MEDIC_GAMING"
});
builder.AddTelegratorWeb(action: builder => builder.Handlers
.CollectHandlersAssemblyWide());