コード例 #1
0
        public void StartCommend(TitanAccount account, CommendInfo info)
        {
            if (_taskDic.ContainsKey(account))
            {
                _log.Warning("Account is already reporting / commending. Aborting forcefully!");

                FinishBotting(account);
            }

            account.FeedCommendInfo(info);

            _successCount = 0;
            _failCount    = 0;
            _count        = 0;

            Titan.Instance.IsBotting = true;

            _log.Debug("Starting commending 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));
                    _count++;

                    switch (result.Result)
                    {
                    case Result.Success:
                        _successCount++;
                        break;

                    case Result.AlreadyLoggedInSomewhereElse:
                        _log.Error("Could not commend 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.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 commend target {Target}.",
                                       info.SteamID.ConvertToUInt64());

                            Titan.Instance.UIManager.SendNotification(
                                "Titan", "Titan was not able to commend your target."
                                );

                            if (Titan.Instance.ParsedObject != null)
                            {
                                Titan.Instance.IsBotting = false;
                            }
                        }
                        else
                        {
                            _log.Information(
                                "SUCCESS! Titan has successfully sent {Amount} out of {Fail} commends to target {Target}.",
                                _successCount, _count, info.SteamID.ConvertToUInt64());

                            Titan.Instance.UIManager.SendNotification(
                                "Titan", _successCount + " commends 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 " +
                               "commend the target after {Timespan} seconds.", account.JsonAccount.Username,
                               timeSpent.Seconds);
                    timedOut = true;
                }
                finally
                {
                    if (timedOut)
                    {
                        account.Stop();
                    }

                    _taskDic.Remove(account);
                }
            }));
        }
コード例 #2
0
ファイル: ThreadManager.cs プロジェクト: metal0/Titan
        public void StartCommend(TitanAccount account, CommendInfo info)
        {
            if (_taskDic.ContainsKey(account))
            {
                _log.Warning("Account is already reporting / commending / idling. Aborting forcefully!");

                FinishBotting(account);
            }

            account.FeedCommendInfo(info);

            _count = 0;

            _log.Debug("Starting commending thread for {Target} using account {Account}.",
                       info.SteamID, account.JsonAccount.Username);

            _taskDic.Add(account, Task.Run(() =>
            {
                var timedOut = false;

                try
                {
                    account.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(account.JsonAccount.Sentry ?
                                                       TimeSpan.FromMinutes(3) : TimeSpan.FromSeconds(60), account.Start);

                    switch (result)
                    {
                    case Result.Success:
                        _count++;

                        if (account.IsLast)
                        {
                            _log.Information("SUCCESS! Titan has successfully sent {Amount} commends to {Target}.",
                                             _count, account._reportInfo.SteamID.ConvertToUInt64());

                            Titan.Instance.UIManager.SendNotification(
                                "Titan", _count + " commends have been successfully sent!"
                                );

                            account.IsLast = false;
                        }
                        break;

                    case Result.AlreadyLoggedInSomewhereElse:
                        _log.Error("Could not commend with account {Account}. The account is " +
                                   "already logged in somewhere else.", account.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).Subtract(new DateTime(account.StartTick));

                    _log.Error("Connection to account {Account} timed out. It was not possible to " +
                               "commend the target after {Timespan} seconds.", account.JsonAccount.Username, timeSpent.Seconds);
                    timedOut = true;
                }
                finally
                {
                    if (timedOut)
                    {
                        account.Stop();
                    }

                    _taskDic.Remove(account);
                }
            }));
        }