diff --git a/src/Telegrator.Hosting.Web/README.md b/src/Telegrator.Hosting.Web/README.md index add827f..6ea54e8 100644 --- a/src/Telegrator.Hosting.Web/README.md +++ b/src/Telegrator.Hosting.Web/README.md @@ -41,7 +41,7 @@ using Telegrator.Hosting.Web; TelegramBotWebHostBuilder builder = TelegramBotWebHost.CreateBuilder(new WebApplicationOptions() { Args = args, - ApplicationName = "Telegrator WebApplication example", + ApplicationName = "TelegramBotWebHost example", }); // Register handlers @@ -58,6 +58,38 @@ telegramBot.Run(); --- +## Application integration Example + +**Program.cs (ASP.NET Core):** +```csharp +using Telegrator.Hosting; +using Telegrator.Hosting.Web; + +// Creating builder +WebApplicationBuilder builder = WebApplication.CreateBuilder(new WebApplicationOptions() +{ + Args = args, + ApplicationName = "WebApplication example", +}); + +// Adding Telegrator +builder.AddTelegratorWeb(); + +// Register handlers +builder.Handlers.CollectHandlersAssemblyWide(); + +// Register your services +builder.Services.AddSingleton(); + +// Building and running application +builder.Build() + .UseTelegratorWeb() + .SetBotCommands(); + .Run(); +``` + +--- + ## Configuration (appsettings.json) ```json diff --git a/src/Telegrator.Hosting/README.md b/src/Telegrator.Hosting/README.md index db92e30..68ad330 100644 --- a/src/Telegrator.Hosting/README.md +++ b/src/Telegrator.Hosting/README.md @@ -55,6 +55,35 @@ telegramBot.Run(); --- +## Application integration Example + +**Program.cs:** +```csharp +using Telegrator.Hosting; + +// Creating builder +HostApplicationBuilder builder = Host.CreateApplicationBuilder(new HostApplicationBuilderSettings() +{ + Args = args, + ApplicationName = "Host example", +}); + +// Adding Telegrator +builder.AddTelegrator(); + +// Registerring handlers (extension) +builder.Handlers.CollectHandlersAssemblyWide(); + +// Building and running application +builder.Build() + .UseTelegrator() + .SetBotCommands() + .Run(); + +``` + +--- + ## Configuration (appsettings.json) ```json