Skip to content

Commit 7e10e6b

Browse files
committed
Push 2FA requests ahead of queue
1 parent 3995b3a commit 7e10e6b

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

ArchiSteamFarm/Bot.cs

+16-2
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,12 @@ internal async Task Start() {
233233
IsRunning = true;
234234

235235
Logging.LogGenericInfo(BotName, "Starting...");
236-
await Program.LimitSteamRequestsAsync().ConfigureAwait(false);
236+
237+
// 2FA tokens are expiring soon, use limiter only when we don't have any pending
238+
if (TwoFactorAuth == null) {
239+
await Program.LimitSteamRequestsAsync().ConfigureAwait(false);
240+
}
241+
237242
SteamClient.Connect();
238243

239244
var fireAndForget = Task.Run(() => HandleCallbacks());
@@ -398,7 +403,12 @@ private async void OnDisconnected(SteamClient.DisconnectedCallback callback) {
398403
}
399404

400405
Logging.LogGenericWarning(BotName, "Disconnected from Steam, reconnecting...");
401-
await Program.LimitSteamRequestsAsync().ConfigureAwait(false);
406+
407+
// 2FA tokens are expiring soon, use limiter only when we don't have any pending
408+
if (TwoFactorAuth == null) {
409+
await Program.LimitSteamRequestsAsync().ConfigureAwait(false);
410+
}
411+
402412
SteamClient.Connect();
403413
}
404414

@@ -533,6 +543,10 @@ private async void OnLoggedOn(SteamUser.LoggedOnCallback callback) {
533543
case EResult.OK:
534544
Logging.LogGenericInfo(BotName, "Successfully logged on!");
535545

546+
// Reset one-time-only access tokens
547+
AuthCode = null;
548+
TwoFactorAuth = null;
549+
536550
if (!SteamNickname.Equals("null")) {
537551
SteamFriends.SetPersonaName(SteamNickname);
538552
}

0 commit comments

Comments
 (0)