Session Updates

This commit is contained in:
FlorianDahn 2020-12-04 17:19:11 +01:00
parent 567a9f937f
commit 4336ff1681
3 changed files with 21 additions and 3 deletions

View File

@ -173,7 +173,7 @@ namespace TelegramBotBase
{
TelegramBotBase.Tools.Console.SetHandler(() =>
{
this.Sessions.SaveSessionStates(this.StateMachine);
this.Sessions.SaveSessionStates();
});
}

View File

@ -115,6 +115,20 @@ namespace TelegramBotBase
return this.SessionList.Where(a => a.Key < 0).Select(a => a.Value).ToList();
}
/// <summary>
/// Loads the previously saved states from the machine.
/// </summary>
public async void LoadSessionStates()
{
if (BotBase.StateMachine == null)
{
return;
}
LoadSessionStates(BotBase.StateMachine);
}
/// <summary>
/// Loads the previously saved states from the machine.
/// </summary>

View File

@ -275,9 +275,13 @@ namespace TelegramBotBase.Sessions
OnMessageSent(new MessageSentEventArgs(m));
}
catch (ApiRequestException)
catch (ApiRequestException ex)
{
return null;
await Task.Delay(ex.Parameters.RetryAfter);
m = await (this.Client.TelegramClient.SendTextMessageAsync(deviceId, text, parseMode, replyToMessageId: replyTo, replyMarkup: markup, disableNotification: disableNotification));
OnMessageSent(new MessageSentEventArgs(m));
}
catch
{