Adding ThrowPendingUpdates option to builder and Message client.

This commit is contained in:
Florian Zevedei
2023-12-09 14:56:02 +01:00
parent 064399ed77
commit c1018ac5a0
3 changed files with 30 additions and 10 deletions
+10
View File
@@ -28,6 +28,14 @@ public class MessageClient
private CancellationTokenSource _cancellationTokenSource;
/// <summary>
/// Indicates if all pending Telegram.Bot.Types.Updates should be thrown out before
// start polling. If set to true Telegram.Bot.Polling.ReceiverOptions.AllowedUpdates
// should be set to not null, otherwise Telegram.Bot.Polling.ReceiverOptions.AllowedUpdates
// will effectively be set to receive all Telegram.Bot.Types.Updates.
/// </summary>
public bool ThrowPendingUpdates { get; set; }
public MessageClient(string apiKey)
{
@@ -114,6 +122,8 @@ public class MessageClient
var receiverOptions = new ReceiverOptions();
receiverOptions.ThrowPendingUpdates = ThrowPendingUpdates;
TelegramClient.StartReceiving(HandleUpdateAsync, HandleErrorAsync, receiverOptions,
_cancellationTokenSource.Token);
}