public void StartMatchResolving(TitanAccount account, LiveGameInfo info) { if (_taskDic.ContainsKey(account)) { _log.Warning("Account is already reporting / commending. Aborting forcefully!"); FinishBotting(account); } account.FeedLiveGameInfo(info); _successCount = 0; _failCount = 0; _count = 0; Titan.Instance.IsBotting = true; _log.Debug("Starting Match ID resolving thread for {Target} using account {Account}.", info.SteamID, account.JsonAccount.Username); _taskDic.Add(account, Task.Run(() => { var timedOut = false; try { account.StartEpoch = DateTime.Now.ToEpochTime(); // Timeout on Sentry Account: 3min (so the user has enough time to input the 2FA code), else 60sec. var origin = Task.Run(() => account.Start()); var result = origin.RunUntil(account.JsonAccount.Sentry ? TimeSpan.FromMinutes(3) : TimeSpan.FromSeconds(60)); switch (result.Result) { case Result.Success: _successCount++; break; case Result.AlreadyLoggedInSomewhereElse: _log.Error("Could not resolve Match ID with account {Account}. The account is " + "already logged in somewhere else.", account.JsonAccount.Username); break; case Result.TimedOut: _log.Error("Processing thread for {Account} has timed out."); break; case Result.SentryRequired: _log.Error("The account has 2FA enabled. Please set {sentry} to {true} " + "in the accounts.json file.", "sentry", true); break; case Result.RateLimit: _log.Error("The Steam Rate Limit has been reached. Please try again in a " + "few minutes."); break; case Result.Code2FAWrong: _log.Error("The provided SteamGuard code was wrong. Please retry."); break; } } catch (TimeoutException) { var timeSpent = DateTime.Now.Subtract(account.StartEpoch.ToDateTime()); _log.Error("Connection to account {Account} timed out. It was not possible to resolve the Match " + "ID for the target after {Timespan} seconds.", account.JsonAccount.Username, timeSpent.Seconds); timedOut = true; } finally { if (timedOut) { account.Stop(); } _taskDic.Remove(account); } })); _successCount = 0; }
private int _count; // Amount of accounts that started reporting / commending public void StartReport(TitanAccount account, ReportInfo info) { if (_taskDic.ContainsKey(account)) { _log.Warning("Account is already reporting / commending. Aborting forcefully!"); FinishBotting(account); } account.FeedReportInfo(info); _successCount = 0; _failCount = 0; _count = 0; Titan.Instance.IsBotting = true; _log.Debug("Starting reporting thread for {Target} in {Match} using account {Account}.", info.SteamID, info.MatchID, account.JsonAccount.Username); _taskDic.Add(account, Task.Run(() => { var timedOut = false; try { account.StartEpoch = DateTime.Now.ToEpochTime(); // Timeout on Sentry Account: 3min (so the user has enough time to input the 2FA code), else 60sec. var origin = Task.Run(() => account.Start()); var result = origin.RunUntil(account.JsonAccount.Sentry ? TimeSpan.FromMinutes(3) : TimeSpan.FromSeconds(60)); _count++; switch (result.Result) { case Result.Success: _successCount++; break; case Result.AlreadyLoggedInSomewhereElse: _log.Error("Could not report with account {Account}. The account is " + "already logged in somewhere else.", account.JsonAccount.Username); _failCount++; break; case Result.AccountBanned: _log.Error("Account {Account} has a cooldown on record. The report has been aborted.", account.JsonAccount.Username); _failCount++; break; case Result.NoMatches: _log.Error("Could not receive match information for {Account}: User is not in live match.", account._liveGameInfo.SteamID.ConvertToUInt64()); _failCount++; break; case Result.TimedOut: _log.Error("Processing thread for {Account} has timed out."); _failCount++; break; case Result.SentryRequired: _log.Error("The account has 2FA enabled. Please set {sentry} to {true} " + "in the accounts.json file.", "sentry", true); _failCount++; break; case Result.RateLimit: _log.Error("The Steam Rate Limit has been reached. Please try again in a " + "few minutes."); _failCount++; break; case Result.Code2FAWrong: _log.Error("The provided SteamGuard code was wrong. Please retry."); _failCount++; break; default: _failCount++; break; } if (_count - _successCount - _failCount == 0) { if (_successCount == 0) { _log.Error("FAIL! Titan was not able to report target {Target}.", info.SteamID.ConvertToUInt64()); Titan.Instance.UIManager.SendNotification( "Titan", "Titan was not able to report your target." ); if (Titan.Instance.ParsedObject != null) { Titan.Instance.IsBotting = false; } } else { _log.Information( "SUCCESS! Titan has successfully sent {Amount} out of {Fail} reports to target {Target}.", _successCount, _count, info.SteamID.ConvertToUInt64()); Titan.Instance.UIManager.SendNotification( "Titan", _successCount + " reports have been successfully sent!" ); if (Titan.Instance.ParsedObject != null) { Titan.Instance.IsBotting = false; } } } } catch (TimeoutException) { var timeSpent = DateTime.Now.Subtract(account.StartEpoch.ToDateTime()); _log.Error("Connection to account {Account} timed out. It was not possible to " + "report the target after {Timespan} seconds.", account.JsonAccount.Username, timeSpent.Seconds); timedOut = true; } finally { if (timedOut) { account.Stop(); } _taskDic.Remove(account); } })); }