2026-03-07 20:46:04 +04:00
|
|
|
using Microsoft.AspNetCore.Builder;
|
2026-04-27 16:28:20 +04:00
|
|
|
using Microsoft.Data.Sqlite;
|
2026-03-07 20:46:04 +04:00
|
|
|
using Microsoft.Extensions.Hosting;
|
2026-04-27 16:28:20 +04:00
|
|
|
using System.Data.Common;
|
2026-03-07 20:46:04 +04:00
|
|
|
|
|
|
|
|
namespace Telegrator;
|
|
|
|
|
|
2026-04-27 09:56:44 +04:00
|
|
|
internal static class Program
|
2026-03-07 20:46:04 +04:00
|
|
|
{
|
|
|
|
|
public static void WebApplicationBuilder_Example(string[] args)
|
|
|
|
|
{
|
|
|
|
|
WebApplicationBuilder builder = WebApplication.CreateBuilder(new WebApplicationOptions()
|
|
|
|
|
{
|
|
|
|
|
Args = args,
|
|
|
|
|
ApplicationName = "WebApplication example",
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-24 00:13:56 +04:00
|
|
|
builder.AddTelegratorWeb(action: builder => builder.Handlers
|
|
|
|
|
.CollectHandlersAssemblyWide());
|
|
|
|
|
|
2026-03-07 20:46:04 +04:00
|
|
|
builder.Build()
|
2026-04-03 19:46:29 +04:00
|
|
|
.UseTelegratorWeb(dontMap: true)
|
2026-04-27 09:56:44 +04:00
|
|
|
.RemapWebhook("https://amazing-butt-sex.cloudpub.ru/")
|
2026-03-07 20:46:04 +04:00
|
|
|
.Run();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void HostApplicationBuilder_Example(string[] args)
|
|
|
|
|
{
|
|
|
|
|
HostApplicationBuilder builder = Host.CreateApplicationBuilder(new HostApplicationBuilderSettings()
|
|
|
|
|
{
|
|
|
|
|
Args = args,
|
|
|
|
|
ApplicationName = "Host example",
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-24 00:13:56 +04:00
|
|
|
builder.AddTelegrator(action: builder => builder.Handlers
|
|
|
|
|
.CollectHandlersAssemblyWide());
|
2026-03-07 20:46:04 +04:00
|
|
|
|
|
|
|
|
builder.Build()
|
|
|
|
|
.UseTelegrator()
|
2026-04-27 16:28:20 +04:00
|
|
|
.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()
|
2026-03-07 20:46:04 +04:00
|
|
|
.Run();
|
|
|
|
|
}
|
|
|
|
|
}
|