Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
voed committed Oct 31, 2023
1 parent 6bc1000 commit 4bee468
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions TGBotFramework/BotFramework/Bot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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; }
Expand All @@ -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)
Expand Down Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 4bee468

Please sign in to comment.