From 4bee468724991369a599bd69ab954335cb2e10d8 Mon Sep 17 00:00:00 2001 From: voed Date: Tue, 31 Oct 2023 23:25:32 +0200 Subject: [PATCH] Small fixes --- TGBotFramework/BotFramework/Bot.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/TGBotFramework/BotFramework/Bot.cs b/TGBotFramework/BotFramework/Bot.cs index ffb28a3..7ca6b23 100644 --- a/TGBotFramework/BotFramework/Bot.cs +++ b/TGBotFramework/BotFramework/Bot.cs @@ -33,7 +33,7 @@ public class Bot: IHostedService, IBotInstance private EventHandlerFactory factory; - private CancellationTokenSource _recieveToken = new CancellationTokenSource(); + private CancellationTokenSource _receiveToken = new CancellationTokenSource(); public Bot(IServiceProvider services, IServiceScopeFactory scopeFactory, Type startupType = null) @@ -53,7 +53,7 @@ async Task IHostedService.StopAsync(CancellationToken cancellationToken) { await client.DeleteWebhookAsync(cancellationToken: cancellationToken); await client.CloseAsync(cancellationToken); - _recieveToken.Cancel(); + _receiveToken.Cancel(); } public string UserName { get; private set; } @@ -70,7 +70,10 @@ private async Task StartListen(CancellationToken cancellationToken) { var apiUrl = _config.BotApiUrl; if(string.IsNullOrWhiteSpace(apiUrl)) + { apiUrl = null; + } + var options = new TelegramBotClientOptions(_config.Token, apiUrl, _config.UseTestEnv); if(_config.UseSOCKS5) @@ -129,7 +132,7 @@ private async Task StartListen(CancellationToken cancellationToken) await client.DeleteWebhookAsync(false, cancellationToken); var receiverOptions = new ReceiverOptions { AllowedUpdates = { }, ThrowPendingUpdates = false }; - client.StartReceiving(HandleUpdateAsync, HandleErrorAsync, receiverOptions, _recieveToken.Token); + client.StartReceiving(HandleUpdateAsync, HandleErrorAsync, receiverOptions, _receiveToken.Token); } }