* Added WideBot csproj data

* Added TelegratorWideClient
* Added WClient extension property for handlers
* Code cleanup
This commit is contained in:
gutii
2026-04-27 16:28:20 +04:00
parent aba9cf4037
commit 0e0a280308
15 changed files with 201 additions and 78 deletions
+61
View File
@@ -0,0 +1,61 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Data.Sqlite;
using Microsoft.Extensions.Hosting;
using System.Data.Common;
namespace Telegrator;
internal static class Program
{
public static void WebApplicationBuilder_Example(string[] args)
{
WebApplicationBuilder builder = WebApplication.CreateBuilder(new WebApplicationOptions()
{
Args = args,
ApplicationName = "WebApplication example",
});
builder.AddTelegratorWeb(action: builder => builder.Handlers
.CollectHandlersAssemblyWide());
builder.Build()
.UseTelegratorWeb(dontMap: true)
.RemapWebhook("https://amazing-butt-sex.cloudpub.ru/")
.Run();
}
public static void HostApplicationBuilder_Example(string[] args)
{
HostApplicationBuilder builder = Host.CreateApplicationBuilder(new HostApplicationBuilderSettings()
{
Args = args,
ApplicationName = "Host example",
});
builder.AddTelegrator(action: builder => builder.Handlers
.CollectHandlersAssemblyWide());
builder.Build()
.UseTelegrator()
.Run();
}
public static void WideBotApplicationBuilder_Example(string[] args)
{
HostApplicationBuilder builder = Host.CreateApplicationBuilder(new HostApplicationBuilderSettings()
{
Args = args,
ApplicationName = "WBot example",
});
using DbConnection connection = new SqliteConnection(@"Data Source=wtgb.db");
builder.Services.ConfigureWideTelegram(new Telegram.Bot.WTelegramBotClientOptions(token: "BOT_TOKEN", apiId: 123, apiHash: "API_HASH", dbConnection: connection));
builder.AddWideTelegrator(action: builder => builder.Handlers
.CollectHandlersAssemblyWide());
builder.Build()
.UseWideTelegrator()
.Run();
}
}
@@ -9,6 +9,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Data.Sqlite" Version="10.0.7" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.6.6" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6" />
@@ -18,6 +19,10 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Telegartor.RedisStateStorage\Telegartor.RedisStateStorage.csproj" />
<ProjectReference Include="..\..\src\Telegrator.Hosting.Web\Telegrator.Hosting.Web.csproj" />
<ProjectReference Include="..\..\src\Telegrator.Hosting.WideBot\Telegrator.Hosting.WideBot.csproj" />
<ProjectReference Include="..\..\src\Telegrator.Localized\Telegrator.Localized.csproj" />
<ProjectReference Include="..\..\src\Telegrator\Telegrator.csproj" />
<ProjectReference Include="..\..\src\Telegrator.Hosting\Telegrator.Hosting.csproj" />
</ItemGroup>