public TSession(BotMode mode, string name = null) { this.Mode = mode; this.Name = name ?? mode.ToString(); }
private int _count; // Amount of accounts that successfully reported or commended public void Start(BotMode mode, TitanAccount acc, uint target, ulong matchId) { acc.Feed(new Info { Mode = mode, Target = target, MatchID = matchId }); _count = 0; _log.Debug("Starting {Mode} thread for {Target} in match {MatchId} " + "using account {Account}.", mode.ToString().ToLower() + "ing", target, matchId, acc.JsonAccount.Username); _taskDic.Add(acc, Task.Run(() => { var timedOut = false; try { acc.StartTick = DateTime.Now.Ticks; // Timeout on Sentry Account: 3min (so the user has enough time to input the 2FA code), else 60sec. var result = WaitFor <Result> .Run(acc.JsonAccount.Sentry ? TimeSpan.FromMinutes(3) : TimeSpan.FromSeconds(60), acc.Start); switch (result) { case Result.Success: _count++; break; case Result.AlreadyLoggedInSomewhereElse: _log.Error("Could not report with account {Account}. The account is " + "already logged in somewhere else.", acc.JsonAccount.Username); break; case Result.AccountBanned: _log.Warning("Account {Account} has VAC or game bans on record. The report may " + "have not been submitted."); _count++; 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; } } catch (TimeoutException) { var timeSpent = new DateTime(DateTime.Now.Ticks - acc.StartTick); _log.Error("Connection to account {Account} timed out. It was not possible to " + "report the target after {Timespan} seconds.", acc.JsonAccount.Username, timeSpent.Second); timedOut = true; } finally { if (timedOut) { acc.Stop(); } _taskDic.Remove(acc); } })); }