diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index ca4e408c1..904c82dfc 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -927,6 +927,8 @@ namespace ArchiSteamFarm { using (IEnumerator iterator = Bots.Values.GetEnumerator()) { string key = reader.ReadLine(); Bot currentBot = this; + bool startHandling = false; + while (!string.IsNullOrEmpty(key) && (currentBot != null)) { if (validate && !IsValidCdKey(key)) { key = reader.ReadLine(); // Next key @@ -969,8 +971,18 @@ namespace ArchiSteamFarm { break; // Next bot, without changing key } - bool alreadyHandled = false; - foreach (Bot bot in Bots.Values.Where(bot => (bot != this) && bot.SteamClient.IsConnected)) { + bool startInnerHandling = false; + bool alreadyInnerHandled = false; + foreach (Bot bot in Bots.Values) { + if (bot == this) { + startInnerHandling = true; + continue; + } + + if (!startInnerHandling || !bot.SteamClient.IsConnected) { + continue; + } + ArchiHandler.PurchaseResponseCallback otherResult = await bot.ArchiHandler.RedeemKey(key).ConfigureAwait(false); if (otherResult == null) { response.Append(Environment.NewLine + "<" + bot.BotName + "> Key: " + key + " | Status: Timeout!"); @@ -981,13 +993,13 @@ namespace ArchiSteamFarm { case ArchiHandler.PurchaseResponseCallback.EPurchaseResult.DuplicatedKey: case ArchiHandler.PurchaseResponseCallback.EPurchaseResult.InvalidKey: case ArchiHandler.PurchaseResponseCallback.EPurchaseResult.OK: - alreadyHandled = true; // This key is already handled, as we either redeemed it or we're sure it's dupe/invalid + alreadyInnerHandled = true; // This key is already handled, as we either redeemed it or we're sure it's dupe/invalid break; } response.Append(Environment.NewLine + "<" + bot.BotName + "> Key: " + key + " | Status: " + otherResult.PurchaseResult + " | Items: " + string.Join("", otherResult.Items)); - if (alreadyHandled) { + if (alreadyInnerHandled) { break; } } @@ -1004,7 +1016,10 @@ namespace ArchiSteamFarm { do { currentBot = iterator.MoveNext() ? iterator.Current : null; - } while ((currentBot == this) || ((currentBot != null) && !currentBot.SteamClient.IsConnected)); + if (currentBot == this) { + startHandling = true; + } + } while (!startHandling || (currentBot == this) || ((currentBot != null) && !currentBot.SteamClient.IsConnected)); } }