Created
May 28, 2022 10:34
-
-
Save kolosovpetro/277b9903a950955ba47142c7f6f7961a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Net.Http; | |
| using Extreme.Bot; | |
| using Extreme.Bot.Services; | |
| using Microsoft.AspNetCore.Builder; | |
| using Microsoft.Extensions.DependencyInjection; | |
| using Telegram.Bot; | |
| var builder = WebApplication.CreateBuilder(args); | |
| var botConfiguration = ConfigurationService.CreateConfiguration(); | |
| builder.Services.AddSingleton(_ => botConfiguration); | |
| builder.Services.AddHostedService<ConfigureWebhook>(); | |
| builder.Services.AddScoped<HandleUpdateService>(); | |
| builder.Services | |
| .AddControllers() | |
| .AddNewtonsoftJson(); | |
| builder.Services.AddEndpointsApiExplorer(); | |
| var httpClient = new HttpClient(); | |
| builder.Services.AddHttpClient<HttpClient>(); | |
| builder.Services.AddSingleton<ITelegramBotClient>(_ => | |
| new TelegramBotClient( | |
| botConfiguration.BotToken, | |
| httpClient, | |
| botConfiguration.BaseUrl)); | |
| var app = builder.Build(); | |
| app.UseTelegramBotWebhook(); | |
| app.UseAuthorization(); | |
| app.MapControllers(); | |
| app.Run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment