diff --git a/Telegrator.Hosting.Web/Polling/HostedUpdateWebhooker.cs b/Telegrator.Hosting.Web/Polling/HostedUpdateWebhooker.cs index b62ac92..7efc0e1 100644 --- a/Telegrator.Hosting.Web/Polling/HostedUpdateWebhooker.cs +++ b/Telegrator.Hosting.Web/Polling/HostedUpdateWebhooker.cs @@ -44,19 +44,22 @@ namespace Telegrator.Hosting.Web.Polling /// public Task StartAsync(CancellationToken cancellationToken) + { + StartInternal(cancellationToken); + return Task.CompletedTask; + } + + private async void StartInternal(CancellationToken cancellationToken) { string pattern = new UriBuilder(_options.WebhookUri).Path; _botHost.MapPost(pattern, (Delegate)ReceiveUpdate); - _botClient.SetWebhook( + await _botClient.SetWebhook( url: _options.WebhookUri, maxConnections: _options.MaxConnections, allowedUpdates: _botHost.UpdateRouter.HandlersProvider.AllowedTypes, dropPendingUpdates: _options.DropPendingUpdates, - cancellationToken: cancellationToken) - .Wait(cancellationToken); - - return Task.CompletedTask; + cancellationToken: cancellationToken); } ///