diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index f00e7f4da..e45a00bb1 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -58,12 +58,11 @@ namespace ArchiSteamFarm { public static IReadOnlyDictionary BotsReadOnly => Bots; internal static ConcurrentDictionary Bots { get; private set; } + internal static StringComparer BotsComparer { get; private set; } private static readonly SemaphoreSlim BotsSemaphore = new SemaphoreSlim(1, 1); private static readonly SemaphoreSlim LoginSemaphore = new SemaphoreSlim(1, 1); - private static RegexOptions BotsRegex; - [PublicAPI] public readonly Actions Actions; @@ -330,10 +329,18 @@ namespace ArchiSteamFarm { } if (botName.StartsWith("r!", StringComparison.OrdinalIgnoreCase)) { - string botPattern = botName.Substring(2); + string botsPattern = botName.Substring(2); try { - Regex regex = new Regex(botPattern, BotsRegex); + RegexOptions botsRegex = RegexOptions.None; + + if ((BotsComparer == StringComparer.InvariantCulture) || (BotsComparer == StringComparer.Ordinal)) { + botsRegex |= RegexOptions.CultureInvariant; + } else if ((BotsComparer == StringComparer.InvariantCultureIgnoreCase) || (BotsComparer == StringComparer.OrdinalIgnoreCase)) { + botsRegex |= RegexOptions.CultureInvariant | RegexOptions.IgnoreCase; + } + + Regex regex = new Regex(botsPattern, botsRegex); IEnumerable regexMatches = Bots.Where(kvp => regex.IsMatch(kvp.Key)).Select(kvp => kvp.Value); result.UnionWith(regexMatches); @@ -816,13 +823,8 @@ namespace ArchiSteamFarm { return; } + BotsComparer = botsComparer; Bots = new ConcurrentDictionary(botsComparer); - - if ((botsComparer == StringComparer.InvariantCulture) || (botsComparer == StringComparer.Ordinal)) { - BotsRegex |= RegexOptions.CultureInvariant; - } else if ((botsComparer == StringComparer.InvariantCultureIgnoreCase) || (botsComparer == StringComparer.OrdinalIgnoreCase)) { - BotsRegex |= RegexOptions.CultureInvariant | RegexOptions.IgnoreCase; - } } internal bool IsBlacklistedFromIdling(uint appID) { diff --git a/ArchiSteamFarm/Commands.cs b/ArchiSteamFarm/Commands.cs index 71e539b99..93b7b88de 100644 --- a/ArchiSteamFarm/Commands.cs +++ b/ArchiSteamFarm/Commands.cs @@ -2080,10 +2080,12 @@ namespace ArchiSteamFarm { HashSet pendingKeys = keys.ToHashSet(); HashSet unusedKeys = pendingKeys.ToHashSet(); + bool firstRound = true; + HashSet rateLimitedBots = new HashSet(); + StringBuilder response = new StringBuilder(); using (HashSet.Enumerator keysEnumerator = pendingKeys.GetEnumerator()) { - HashSet rateLimitedBots = new HashSet(); string key = keysEnumerator.MoveNext() ? keysEnumerator.Current : null; // Initial key while (!string.IsNullOrEmpty(key)) { @@ -2241,6 +2243,26 @@ namespace ArchiSteamFarm { // b) When we're skipping initial bot AND we have forwarding enabled, otherwise we won't get down to other accounts if (distribute || (forward && redeemFlags.HasFlag(ERedeemFlags.SkipInitial))) { currentBot = botsEnumerator.MoveNext() ? botsEnumerator.Current : null; + + if (!firstRound) { + continue; + } + + firstRound = false; + + if (currentBot == null) { + continue; + } + + while (Bot.BotsComparer.Compare(currentBot.BotName, Bot.BotName) <= 0) { + if (!botsEnumerator.MoveNext()) { + currentBot = null; + + break; + } + + currentBot = botsEnumerator.Current; + } } } }