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-05-01 20:48:32 +04:00
|
|
|
using Telegram.Bot.Polling;
|
2026-03-07 20:46:04 +04:00
|
|
|
|
2026-04-27 21:07:02 +04:00
|
|
|
namespace Telegrator.Tests;
|
2026-03-07 20:46:04 +04:00
|
|
|
|
2026-04-27 09:56:44 +04:00
|
|
|
internal static class Program
|
2026-03-07 20:46:04 +04:00
|
|
|
{
|
|
|
|
|
public static void HostApplicationBuilder_Example(string[] args)
|
|
|
|
|
{
|
|
|
|
|
HostApplicationBuilder builder = Host.CreateApplicationBuilder(new HostApplicationBuilderSettings()
|
|
|
|
|
{
|
|
|
|
|
Args = args,
|
|
|
|
|
ApplicationName = "Host example",
|
|
|
|
|
});
|
|
|
|
|
|
2026-05-01 20:48:32 +04:00
|
|
|
builder.Services.ConfigureReceiver(new ReceiverOptions()
|
|
|
|
|
{
|
|
|
|
|
DropPendingUpdates = true,
|
|
|
|
|
Limit = 100
|
|
|
|
|
});
|
|
|
|
|
|
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",
|
|
|
|
|
});
|
|
|
|
|
|
2026-05-01 20:48:32 +04:00
|
|
|
builder.Services.ConfigureWideBot(new WideBotOptions()
|
|
|
|
|
{
|
|
|
|
|
ApiId = 123,
|
|
|
|
|
ApiHash = "API_HASH",
|
|
|
|
|
DropPendingUpdates = true,
|
|
|
|
|
});
|
2026-04-27 16:28:20 +04:00
|
|
|
|
2026-05-01 20:48:32 +04:00
|
|
|
builder.AddWideTelegrator(
|
|
|
|
|
dbConnectionFactory: provider => new SqliteConnection($"Data Source={Environment.ExpandEnvironmentVariables("%AppData%\\Telegrator\\%wtgb.db")}"),
|
|
|
|
|
action: builder => builder.Handlers.CollectHandlersAssemblyWide());
|
2026-04-27 16:28:20 +04:00
|
|
|
|
|
|
|
|
builder.Build()
|
|
|
|
|
.UseWideTelegrator()
|
2026-03-07 20:46:04 +04:00
|
|
|
.Run();
|
|
|
|
|
}
|
2026-04-27 21:07:02 +04:00
|
|
|
|
|
|
|
|
public static void WebApplicationBuilder_Example(string[] args)
|
|
|
|
|
{
|
|
|
|
|
WebApplicationBuilder builder = WebApplication.CreateBuilder(new WebApplicationOptions()
|
|
|
|
|
{
|
|
|
|
|
Args = args,
|
|
|
|
|
ApplicationName = "WebApplication example",
|
|
|
|
|
});
|
|
|
|
|
|
2026-05-01 20:48:32 +04:00
|
|
|
builder.Services.ConfigureWebhooker(new WebhookerOptions()
|
|
|
|
|
{
|
|
|
|
|
WebhookUri = "https://medic-gaming.com/",
|
|
|
|
|
DropPendingUpdates = true,
|
|
|
|
|
SecretToken = "MEDIC_GAMING"
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-27 21:07:02 +04:00
|
|
|
builder.AddTelegratorWeb(action: builder => builder.Handlers
|
|
|
|
|
.CollectHandlersAssemblyWide());
|
|
|
|
|
|
|
|
|
|
builder.Build()
|
|
|
|
|
.UseTelegratorWeb(dontMap: true)
|
|
|
|
|
.RemapWebhook("https://amazing-butt-sex.cloudpub.ru/")
|
|
|
|
|
.Run();
|
|
|
|
|
}
|
2026-03-07 20:46:04 +04:00
|
|
|
}
|