From d016acd39f90e8a497ec7995fd053eab06d8c9ad Mon Sep 17 00:00:00 2001 From: JustArchi Date: Wed, 26 Dec 2018 17:25:08 +0100 Subject: [PATCH] Add warning about excessive bots count --- ArchiSteamFarm/ASF.cs | 19 +++++++++++++++++-- .../Localization/Strings.Designer.cs | 9 +++++++++ ArchiSteamFarm/Localization/Strings.resx | 3 +++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/ArchiSteamFarm/ASF.cs b/ArchiSteamFarm/ASF.cs index 637189293..dd8c63116 100644 --- a/ArchiSteamFarm/ASF.cs +++ b/ArchiSteamFarm/ASF.cs @@ -21,6 +21,7 @@ using System; using System.Collections.Concurrent; +using System.Collections.Generic; using System.IO; using System.IO.Compression; using System.Linq; @@ -31,6 +32,9 @@ using ArchiSteamFarm.NLog; namespace ArchiSteamFarm { internal static class ASF { + // This is based on internal Valve guidelines, we're not using it as a hard limit + private const byte MaximumRecommendedBotsCount = 10; + internal static readonly ArchiLogger ArchiLogger = new ArchiLogger(SharedInfo.ASF); private static readonly ConcurrentDictionary LastWriteEvents = new ConcurrentDictionary(); @@ -47,17 +51,28 @@ namespace ArchiSteamFarm { // Before attempting to connect, initialize our configuration await Bot.InitializeSteamConfiguration(Program.GlobalConfig.SteamProtocols, Program.GlobalDatabase.CellID, Program.GlobalDatabase.ServerListProvider).ConfigureAwait(false); + HashSet botNames; + try { - await Utilities.InParallel(Directory.EnumerateFiles(SharedInfo.ConfigDirectory, "*" + SharedInfo.ConfigExtension).Select(Path.GetFileNameWithoutExtension).Where(botName => !string.IsNullOrEmpty(botName) && IsValidBotName(botName)).OrderBy(botName => botName).Select(Bot.RegisterBot)).ConfigureAwait(false); + botNames = Directory.EnumerateFiles(SharedInfo.ConfigDirectory, "*" + SharedInfo.ConfigExtension).Select(Path.GetFileNameWithoutExtension).Where(botName => !string.IsNullOrEmpty(botName) && IsValidBotName(botName)).ToHashSet(); } catch (Exception e) { ArchiLogger.LogGenericException(e); return; } - if (Bot.Bots.Count == 0) { + if (botNames.Count == 0) { ArchiLogger.LogGenericWarning(Strings.ErrorNoBotsDefined); + + return; } + + if (botNames.Count > MaximumRecommendedBotsCount) { + ArchiLogger.LogGenericWarning(string.Format(Strings.WarningExcessiveBotsCount, MaximumRecommendedBotsCount)); + await Task.Delay(10000).ConfigureAwait(false); + } + + await Utilities.InParallel(botNames.OrderBy(botName => botName).Select(Bot.RegisterBot)).ConfigureAwait(false); } internal static void InitEvents() { diff --git a/ArchiSteamFarm/Localization/Strings.Designer.cs b/ArchiSteamFarm/Localization/Strings.Designer.cs index 6d81d6d50..48e62cb76 100644 --- a/ArchiSteamFarm/Localization/Strings.Designer.cs +++ b/ArchiSteamFarm/Localization/Strings.Designer.cs @@ -1422,6 +1422,15 @@ namespace ArchiSteamFarm.Localization { } } + /// + /// Wyszukuje zlokalizowany ciąg podobny do ciągu You're running more personal bot accounts than our upper recommended limit ({0}). Be advised that this setup is not supported and might cause various Steam-related issues, including account suspensions. Check out the FAQ for more details.. + /// + internal static string WarningExcessiveBotsCount { + get { + return ResourceManager.GetString("WarningExcessiveBotsCount", resourceCulture); + } + } + /// /// Wyszukuje zlokalizowany ciąg podobny do ciągu Failed!. /// diff --git a/ArchiSteamFarm/Localization/Strings.resx b/ArchiSteamFarm/Localization/Strings.resx index 726f1debb..56d43f9d8 100644 --- a/ArchiSteamFarm/Localization/Strings.resx +++ b/ArchiSteamFarm/Localization/Strings.resx @@ -675,4 +675,7 @@ StackTrace: Matched a total of {0} sets this round. {0} will be replaced by number of sets traded + + You're running more personal bot accounts than our upper recommended limit ({0}). Be advised that this setup is not supported and might cause various Steam-related issues, including account suspensions. Check out the FAQ for more details. + \ No newline at end of file