diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index 29e9f8aac..bc9786d4d 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -44,6 +44,7 @@ namespace ArchiSteamFarm { internal static readonly Dictionary Bots = new Dictionary(); private static readonly uint LoginID = MsgClientLogon.ObfuscationMask; // This must be the same for all ASF bots and all ASF processes + private static readonly SemaphoreSlim SteamSemaphore = new SemaphoreSlim(1); internal readonly string BotName; internal readonly ArchiHandler ArchiHandler; @@ -105,6 +106,14 @@ namespace ArchiSteamFarm { return Regex.IsMatch(key, @"[0-9A-Z]{4,5}-[0-9A-Z]{4,5}-[0-9A-Z]{4,5}-?(?:(?:[0-9A-Z]{4,5}-?)?(?:[0-9A-Z]{4,5}))?"); } + private static async Task LimitSteamRequestsAsync() { + await SteamSemaphore.WaitAsync().ConfigureAwait(false); + Task.Run(async () => { + await Utilities.SleepAsync(Program.GlobalConfig.LoginLimiterDelay * 1000).ConfigureAwait(false); + SteamSemaphore.Release(); + }).Forget(); + } + internal Bot(string botName) { if (string.IsNullOrEmpty(botName)) { throw new ArgumentNullException("botName"); @@ -412,7 +421,7 @@ namespace ArchiSteamFarm { // 2FA tokens are expiring soon, don't use limiter when user is providing one if (TwoFactorCode == null || BotDatabase.SteamGuardAccount != null) { - await Program.LimitSteamRequestsAsync().ConfigureAwait(false); + await LimitSteamRequestsAsync().ConfigureAwait(false); } Logging.LogGenericInfo("Starting...", BotName); @@ -1424,7 +1433,7 @@ namespace ArchiSteamFarm { // 2FA tokens are expiring soon, don't use limiter when user is providing one if (TwoFactorCode == null || BotDatabase.SteamGuardAccount != null) { - await Program.LimitSteamRequestsAsync().ConfigureAwait(false); + await LimitSteamRequestsAsync().ConfigureAwait(false); } SteamClient.Connect(); diff --git a/ArchiSteamFarm/Program.cs b/ArchiSteamFarm/Program.cs index e2730d676..323b8f26b 100644 --- a/ArchiSteamFarm/Program.cs +++ b/ArchiSteamFarm/Program.cs @@ -68,7 +68,6 @@ namespace ArchiSteamFarm { internal static readonly Version Version = Assembly.GetEntryAssembly().GetName().Version; private static readonly object ConsoleLock = new object(); - private static readonly SemaphoreSlim SteamSemaphore = new SemaphoreSlim(1); private static readonly ManualResetEventSlim ShutdownResetEvent = new ManualResetEventSlim(false); private static readonly string ExecutableFile = Assembly.GetEntryAssembly().Location; private static readonly string ExecutableName = Path.GetFileName(ExecutableFile); @@ -278,14 +277,6 @@ namespace ArchiSteamFarm { Exit(); } - internal static async Task LimitSteamRequestsAsync() { - await SteamSemaphore.WaitAsync().ConfigureAwait(false); - Task.Run(async () => { - await Utilities.SleepAsync(GlobalConfig.LoginLimiterDelay * 1000).ConfigureAwait(false); - SteamSemaphore.Release(); - }).Forget(); - } - internal static string GetUserInput(EUserInputType userInputType, string botName = null, string extraInformation = null) { if (userInputType == EUserInputType.Unknown) { return null;