Use generic delay for all unhandled disconnects

There are only handful of cases where we want to reconnect immediately, and login limiter delay usually kills those anyway
This commit is contained in:
Archi
2022-03-21 14:50:36 +01:00
parent 94e70e5ac2
commit 0c3dfaa4ae

View File

@@ -2384,18 +2384,10 @@ public sealed class Bot : IAsyncDisposable {
// Do not attempt to reconnect, those failures are permanent
return;
case EResult.InvalidPassword when !string.IsNullOrEmpty(BotDatabase.LoginKey):
// We can retry immediately
BotDatabase.LoginKey = null;
ArchiLogger.LogGenericInfo(Strings.BotRemovedExpiredLoginKey);
break;
case EResult.InvalidPassword:
case EResult.NoConnection:
case EResult.ServiceUnavailable:
case EResult.Timeout:
case EResult.TryAnotherCM:
case EResult.TwoFactorCodeMismatch:
await Task.Delay(5000).ConfigureAwait(false);
break;
case EResult.RateLimitExceeded:
ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.BotRateLimitExceeded, TimeSpan.FromMinutes(LoginCooldownInMinutes).ToHumanReadable()));
@@ -2410,6 +2402,11 @@ public sealed class Bot : IAsyncDisposable {
ASF.LoginRateLimitingSemaphore.Release();
}
break;
default:
// Generic delay before retrying
await Task.Delay(5000).ConfigureAwait(false);
break;
}