From 65968b430292d90d552f1066e89dc698babdbc9b Mon Sep 17 00:00:00 2001 From: JustArchi Date: Sat, 23 Feb 2019 08:40:56 +0100 Subject: [PATCH] Respect custom BotsComparer when navigating through bot names --- ArchiSteamFarm/ASF.cs | 2 +- ArchiSteamFarm/Bot.cs | 4 ++-- ArchiSteamFarm/Commands.cs | 4 ++-- ArchiSteamFarm/IPC/Controllers/Api/CommandController.cs | 2 +- ArchiSteamFarm/NLog/Logging.cs | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ArchiSteamFarm/ASF.cs b/ArchiSteamFarm/ASF.cs index 426613773..107e7e152 100644 --- a/ArchiSteamFarm/ASF.cs +++ b/ArchiSteamFarm/ASF.cs @@ -599,7 +599,7 @@ namespace ArchiSteamFarm { await Task.Delay(10000).ConfigureAwait(false); } - await Utilities.InParallel(botNames.OrderBy(botName => botName).Select(Bot.RegisterBot)).ConfigureAwait(false); + await Utilities.InParallel(botNames.OrderBy(botName => botName, Bot.BotsComparer).Select(Bot.RegisterBot)).ConfigureAwait(false); } private static async Task UpdateAndRestart() { diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index e45a00bb1..1e6e5d255 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -306,7 +306,7 @@ namespace ArchiSteamFarm { foreach (string botName in botNames) { if (botName.Equals(SharedInfo.ASF, StringComparison.OrdinalIgnoreCase)) { - IEnumerable allBots = Bots.OrderBy(bot => bot.Key).Select(bot => bot.Value); + IEnumerable allBots = Bots.OrderBy(bot => bot.Key, BotsComparer).Select(bot => bot.Value); result.UnionWith(allBots); return result; @@ -316,7 +316,7 @@ namespace ArchiSteamFarm { string[] botRange = botName.Split(new[] { ".." }, StringSplitOptions.RemoveEmptyEntries); if ((botRange.Length == 2) && Bots.TryGetValue(botRange[0], out Bot firstBot) && Bots.TryGetValue(botRange[1], out Bot lastBot)) { - foreach (Bot bot in Bots.OrderBy(bot => bot.Key).Select(bot => bot.Value).SkipWhile(bot => bot != firstBot)) { + foreach (Bot bot in Bots.OrderBy(bot => bot.Key, BotsComparer).Select(bot => bot.Value).SkipWhile(bot => bot != firstBot)) { result.Add(bot); if (bot == lastBot) { diff --git a/ArchiSteamFarm/Commands.cs b/ArchiSteamFarm/Commands.cs index 93b7b88de..2b0467c82 100644 --- a/ArchiSteamFarm/Commands.cs +++ b/ArchiSteamFarm/Commands.cs @@ -2091,7 +2091,7 @@ namespace ArchiSteamFarm { while (!string.IsNullOrEmpty(key)) { string startingKey = key; - using (IEnumerator botsEnumerator = Bot.Bots.Where(bot => (bot.Value != Bot) && !rateLimitedBots.Contains(bot.Value) && bot.Value.IsConnectedAndLoggedOn && bot.Value.Commands.Bot.HasPermission(steamID, BotConfig.EPermission.Operator)).OrderBy(bot => bot.Key).Select(bot => bot.Value).GetEnumerator()) { + using (IEnumerator botsEnumerator = Bot.Bots.Where(bot => (bot.Value != Bot) && !rateLimitedBots.Contains(bot.Value) && bot.Value.IsConnectedAndLoggedOn && bot.Value.Commands.Bot.HasPermission(steamID, BotConfig.EPermission.Operator)).OrderBy(bot => bot.Key, Bot.BotsComparer).Select(bot => bot.Value).GetEnumerator()) { Bot currentBot = Bot; while (!string.IsNullOrEmpty(key) && (currentBot != null)) { @@ -2172,7 +2172,7 @@ namespace ArchiSteamFarm { bool alreadyHandled = false; - foreach (Bot innerBot in Bot.Bots.Where(bot => (bot.Value != currentBot) && (!redeemFlags.HasFlag(ERedeemFlags.SkipInitial) || (bot.Value != Bot)) && !rateLimitedBots.Contains(bot.Value) && bot.Value.IsConnectedAndLoggedOn && bot.Value.Commands.Bot.HasPermission(steamID, BotConfig.EPermission.Operator) && ((items.Count == 0) || items.Keys.Any(packageID => !bot.Value.OwnedPackageIDs.ContainsKey(packageID)))).OrderBy(bot => bot.Key).Select(bot => bot.Value)) { + foreach (Bot innerBot in Bot.Bots.Where(bot => (bot.Value != currentBot) && (!redeemFlags.HasFlag(ERedeemFlags.SkipInitial) || (bot.Value != Bot)) && !rateLimitedBots.Contains(bot.Value) && bot.Value.IsConnectedAndLoggedOn && bot.Value.Commands.Bot.HasPermission(steamID, BotConfig.EPermission.Operator) && ((items.Count == 0) || items.Keys.Any(packageID => !bot.Value.OwnedPackageIDs.ContainsKey(packageID)))).OrderBy(bot => bot.Key, Bot.BotsComparer).Select(bot => bot.Value)) { ArchiHandler.PurchaseResponseCallback otherResult = await innerBot.Actions.RedeemKey(key).ConfigureAwait(false); if (otherResult == null) { diff --git a/ArchiSteamFarm/IPC/Controllers/Api/CommandController.cs b/ArchiSteamFarm/IPC/Controllers/Api/CommandController.cs index b74859b78..ee1176178 100644 --- a/ArchiSteamFarm/IPC/Controllers/Api/CommandController.cs +++ b/ArchiSteamFarm/IPC/Controllers/Api/CommandController.cs @@ -49,7 +49,7 @@ namespace ArchiSteamFarm.IPC.Controllers.Api { return BadRequest(new GenericResponse(false, string.Format(Strings.ErrorIsInvalid, nameof(ASF.GlobalConfig.SteamOwnerID)))); } - Bot targetBot = Bot.Bots.OrderBy(bot => bot.Key).Select(bot => bot.Value).FirstOrDefault(); + Bot targetBot = Bot.Bots.OrderBy(bot => bot.Key, Bot.BotsComparer).Select(bot => bot.Value).FirstOrDefault(); if (targetBot == null) { return BadRequest(new GenericResponse(false, Strings.ErrorNoBotsDefined)); diff --git a/ArchiSteamFarm/NLog/Logging.cs b/ArchiSteamFarm/NLog/Logging.cs index 82802e1ef..4f975c427 100644 --- a/ArchiSteamFarm/NLog/Logging.cs +++ b/ArchiSteamFarm/NLog/Logging.cs @@ -273,7 +273,7 @@ namespace ArchiSteamFarm.NLog { } } - Bot targetBot = Bot.Bots.OrderBy(bot => bot.Key).Select(bot => bot.Value).FirstOrDefault(); + Bot targetBot = Bot.Bots.OrderBy(bot => bot.Key, Bot.BotsComparer).Select(bot => bot.Value).FirstOrDefault(); if (targetBot == null) { Console.WriteLine(@"<< " + Strings.ErrorNoBotsDefined);