Update DeviceSession.cs

Workaround: Unknown API differences
This commit is contained in:
FlorianDahn 2020-12-23 03:09:47 +01:00
parent 73ba36ea2b
commit a524fef0d5

View File

@ -642,7 +642,7 @@ namespace TelegramBotBase.Sessions
{ {
try try
{ {
await API(a => a.DeleteMessageAsync(this.DeviceId, messageId)); await this.Client.TelegramClient.DeleteMessageAsync(this.DeviceId, messageId);
return true; return true;
} }
@ -754,6 +754,8 @@ namespace TelegramBotBase.Sessions
return await call(this.Client.TelegramClient); return await call(this.Client.TelegramClient);
} }
catch (ApiRequestException ex) catch (ApiRequestException ex)
{
if (ex.Parameters != null)
{ {
await Task.Delay(ex.Parameters.RetryAfter); await Task.Delay(ex.Parameters.RetryAfter);
@ -761,10 +763,12 @@ namespace TelegramBotBase.Sessions
} }
} }
return default(T);
}
/// <summary> /// <summary>
/// This will call a function on the TelegramClient and automatically Retry if an limit has been exceeded. /// This will call a function on the TelegramClient and automatically Retry if an limit has been exceeded.
/// </summary> /// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="call"></param> /// <param name="call"></param>
/// <returns></returns> /// <returns></returns>
public async Task API(Func<Telegram.Bot.TelegramBotClient, Task> call) public async Task API(Func<Telegram.Bot.TelegramBotClient, Task> call)
@ -774,12 +778,15 @@ namespace TelegramBotBase.Sessions
await call(this.Client.TelegramClient); await call(this.Client.TelegramClient);
} }
catch (ApiRequestException ex) catch (ApiRequestException ex)
{
if (ex.Parameters != null)
{ {
await Task.Delay(ex.Parameters.RetryAfter); await Task.Delay(ex.Parameters.RetryAfter);
await call(this.Client.TelegramClient); await call(this.Client.TelegramClient);
} }
} }
}
#region "Events" #region "Events"