This commit is contained in:
JustArchi
2016-04-23 16:36:43 +02:00
parent ac7ecb6bb4
commit 048b0fb538
2 changed files with 11 additions and 11 deletions

View File

@@ -44,6 +44,7 @@ namespace ArchiSteamFarm {
internal static readonly Dictionary<string, Bot> Bots = new Dictionary<string, Bot>();
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();

View File

@@ -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;