2026-03-07 20:46:04 +04:00
|
|
|
using Microsoft.AspNetCore.Builder;
|
2026-03-08 19:43:48 +04:00
|
|
|
using Microsoft.Extensions.Configuration;
|
2026-03-07 20:46:04 +04:00
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
|
using Telegrator.Hosting;
|
|
|
|
|
using Telegrator.Hosting.Web;
|
|
|
|
|
|
|
|
|
|
namespace Telegrator;
|
|
|
|
|
|
|
|
|
|
internal class Program
|
|
|
|
|
{
|
|
|
|
|
public static void TelegramBotWebHostBuilder_Example(string[] args)
|
|
|
|
|
{
|
|
|
|
|
TelegramBotWebHostBuilder builder = TelegramBotWebHost.CreateBuilder(new WebApplicationOptions()
|
|
|
|
|
{
|
|
|
|
|
Args = args,
|
|
|
|
|
ApplicationName = "TelegramBotWebHost example",
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-24 00:13:56 +04:00
|
|
|
builder.Handlers
|
|
|
|
|
.CollectHandlersAssemblyWide();
|
2026-03-07 20:46:04 +04:00
|
|
|
|
|
|
|
|
builder.Build()
|
|
|
|
|
.AddLoggingAdapter()
|
|
|
|
|
.SetBotCommands()
|
|
|
|
|
.Run();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
.RemapWebhook("https://awesome-butt-sex.cloudpub.ru/")
|
2026-03-07 20:46:04 +04:00
|
|
|
.AddLoggingAdapter()
|
|
|
|
|
.SetBotCommands()
|
|
|
|
|
.Run();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void TelegramBotHostBuilder_Example(string[] args)
|
|
|
|
|
{
|
2026-03-08 19:43:48 +04:00
|
|
|
ConfigurationManager configuration = new ConfigurationManager();
|
|
|
|
|
configuration.AddJsonFile("appsettings.json");
|
|
|
|
|
|
2026-03-07 20:46:04 +04:00
|
|
|
TelegramBotHostBuilder builder = TelegramBotHost.CreateBuilder(new HostApplicationBuilderSettings()
|
|
|
|
|
{
|
|
|
|
|
Args = args,
|
|
|
|
|
ApplicationName = "TelegramBotHost example",
|
2026-03-08 19:43:48 +04:00
|
|
|
Configuration = configuration
|
2026-03-07 20:46:04 +04:00
|
|
|
});
|
|
|
|
|
|
2026-04-24 00:13:56 +04:00
|
|
|
builder.Handlers
|
|
|
|
|
.CollectHandlersAssemblyWide();
|
2026-03-07 20:46:04 +04:00
|
|
|
|
|
|
|
|
builder.Build()
|
|
|
|
|
.AddLoggingAdapter()
|
|
|
|
|
.SetBotCommands()
|
|
|
|
|
.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()
|
|
|
|
|
.AddLoggingAdapter()
|
|
|
|
|
.SetBotCommands()
|
|
|
|
|
.Run();
|
|
|
|
|
}
|
|
|
|
|
}
|