예제 #1
0
        /// <summary>
        /// Подтверждение в мобильном приложении
        /// </summary>
        /// <param name="sgAccount"></param>
        void AcceptConfirmations(string nick)
        {
            try
            {
                _mobileAccount.Session.SteamLogin       = _account.FindCookieByName("steamlogin").Value;
                _mobileAccount.Session.SteamLoginSecure = _account.FindCookieByName("steamloginsecure").Value;

                _mobileAccount.AcceptConfirmation(new Confirmation()
                {
                });
                foreach (Confirmation confirmation in _mobileAccount.FetchConfirmations())
                {
                    //Подтверждение трейдов не с маркета

                    // if (confirmation.Description.ToLower().Contains(nick.ToLower()))
                    if (_mobileAccount.AcceptConfirmation(confirmation))
                    {
                        Console.WriteLine("Подтвержден в приложении");
                    }
                }
            }
            catch
            {
            }
        }
예제 #2
0
        /// <summary>
        /// If we didn't link our mobile via the bot, just return a message
        /// If we did link our mobile via the bot, we have to get the SteamLogin and SteamLoginSecure, which we get from logging in to the web
        /// Pass the sessionID because we need it aswell, generate a uint64 SteamID from the SessionID, without this we can't fetch the confirmations
        /// With these values we can get all confirmations and accept or deny them, without it will throw errors
        /// </summary>
        public async Task ConfirmAllTrades(string _steamLogin, string _steamLoginSecure, string _sessionID)
        {
            if (m_steamGuardAccount == null)
            {
                m_logger.Warning("Bot account does not have 2FA enabled.");
            }
            else
            {
                m_steamGuardAccount.Session = new SessionData
                {
                    SteamLogin       = _steamLogin,
                    SteamLoginSecure = _steamLoginSecure,
                    SessionID        = _sessionID,
                    SteamID          = new SteamID(Encoding.UTF8.GetString(Convert.FromBase64String(_sessionID))).ConvertToUInt64()
                };

                bool           hasToRelog    = false;
                Confirmation[] confirmations = null;

                try
                {
                    confirmations = await m_steamGuardAccount.FetchConfirmationsAsync().ConfigureAwait(false);
                }
                catch (SteamGuardAccount.WGTokenInvalidException exception)
                {
                    hasToRelog = true;
                }

                if (confirmations != null)
                {
                    foreach (Confirmation confirmation in confirmations)
                    {
                        bool confirmedTrade = m_steamGuardAccount.AcceptConfirmation(confirmation);

                        if (confirmedTrade)
                        {
                            m_logger.Info($"Confirmed {confirmation.Key}, {confirmation.IntType}/{confirmation.Creator}(Confirmation ID #{confirmation.ID})");
                        }
                        else
                        {
                            m_logger.Warning($"Could not confirm {confirmation.Key}, (Confirmation ID #{confirmation.ID})");
                        }
                    }
                }
                else
                {
                    if (hasToRelog)
                    {
                        await m_steamGuardAccount.RefreshSessionAsync().ConfigureAwait(false);
                    }
                }
            }
        }
예제 #3
0
 private static void AcceptConfirmationsLoop(SteamGuardAccount sgAccount)
 {
     sgAccount.Session.SteamLogin       = _account.FindCookieByName("steamlogin").Value;
     sgAccount.Session.SteamLoginSecure = _account.FindCookieByName("steamloginsecure").Value;
     while (true) //permanent loop, can be changed
     {
         Thread.Sleep(10000);
         foreach (Confirmation confirmation in sgAccount.FetchConfirmations())
         {
             sgAccount.AcceptConfirmation(confirmation);
         }
     }
 }
예제 #4
0
        /// <summary>
        /// Accepts all pending trade for the account from clicking on the submenu item for the account
        /// </summary>
        private void menuAcceptTrades_Click(object sender, EventArgs e)
        {
            SteamGuardAccount account = GetAccountFromMenuItem(sender);

            if (account != null)
            {
                foreach (Confirmation confirmation in LoadConfirmations(account))
                {
                    account.AcceptConfirmation(confirmation);
                }
                Console.Beep(800, 50);
            }
        }
예제 #5
0
        /// <summary>
        /// Подтверждение в мобильном приложении
        /// </summary>
        /// <param name="sgAccount"></param>
        void AcceptConfirmations()
        {
            try
            {
                _mobileAccount.Session.SteamLogin       = _account.FindCookieByName("steamlogin").Value;
                _mobileAccount.Session.SteamLoginSecure = _account.FindCookieByName("steamloginsecure").Value;

                _mobileAccount.AcceptConfirmation(new Confirmation()
                {
                });
                foreach (Confirmation confirmation in _mobileAccount.FetchConfirmations())
                {
                    if (_mobileAccount.AcceptConfirmation(confirmation))
                    {
                        Console.WriteLine("Подтвержден в приложении");
                    }
                }
            }
            catch
            {
            }
        }
 private void btnAccept_Click(object sender, EventArgs e)
 {
     if (!accept2)
     {
         // Allow user to confirm first
         lblStatus.Text      = "再按接受确认";
         btnAccept.BackColor = Color.FromArgb(128, 255, 128);
         accept2             = true;
     }
     else
     {
         lblStatus.Text = "接受中...";
         acc.AcceptConfirmation(confirms[0]);
         confirms.RemoveAt(0);
         Reset();
     }
 }
예제 #7
0
        private void btnAcceptConfirmation_Click(object sender, EventArgs e)
        {
            if (mCurrentConfirmation == null)
            {
                return;
            }
            bool success = mCurrentAccount.AcceptConfirmation(mCurrentConfirmation);

            if (success)
            {
                MessageBox.Show("Confirmation successfully accepted.");
            }
            else
            {
                MessageBox.Show("Unable to accept confirmation.");
            }
            this.loadConfirmations();
        }
예제 #8
0
        /// <summary>
        /// If we didn't link our mobile via the bot, just return a message
        /// If we did link our mobile via the bot, we have to get the SteamLogin and SteamLoginSecure, which we get from logging in to the web
        /// Pass the sessionID because we need it aswell, generate a uint64 SteamID from the SessionID, without this we can't fetch the confirmations
        /// With these values we can get all confirmations and accept or deny them, without it will throw errors
        /// </summary>
        public void ConfirmAllTrades(string _steamLogin, string _steamLoginSecure, string _sessionID)
        {
            if (m_steamGuardAccount == null)
            {
                m_logger.Warning("Bot account does not have 2FA enabled.");
            }
            else
            {
                m_steamGuardAccount.Session = new SessionData
                {
                    SteamLogin       = _steamLogin,
                    SteamLoginSecure = _steamLoginSecure,
                    SessionID        = _sessionID,
                    SteamID          = new SteamID(Encoding.UTF8.GetString(Convert.FromBase64String(_sessionID))).ConvertToUInt64()
                };

                Confirmation[] confirmations = m_steamGuardAccount.FetchConfirmations();

                if (confirmations != null)
                {
                    foreach (Confirmation confirmation in confirmations)
                    {
                        bool confirmedTrade = m_steamGuardAccount.AcceptConfirmation(confirmation);

                        if (confirmedTrade)
                        {
                            m_logger.Info($"Confirmed {confirmation.Description}, (Confirmation ID #{confirmation.ID})");
                        }
                        else
                        {
                            m_logger.Warning($"Could not confirm {confirmation.Description}, (Confirmation ID #{confirmation.ID})");
                        }
                    }
                }
                else
                {
                    m_logger.Error("Mobilehelper: Must Login");
                }
            }
        }
예제 #9
0
        /// ///////////////////////////////////////////////////////////////

        /*public void CreateTradeOffer(string otherSteamID)
         * {
         *  List<long> contextId = new List<long>();
         *  contextId.Add(2);
         *  MyGenericInventory.load((int)Games.TF2, contextId, steamClient.SteamID);
         *
         *  SteamID partenar = new SteamID(otherSteamID);
         *  TradeOffer to = tradeOfferManager.NewOffer(partenar);
         *
         *  GenericInventory.Item test = MyGenericInventory.items.FirstOrDefault().Value;
         *
         *  to.Items.AddMyItem(test.appid, test.contextid, (long)test.assetid);
         *
         *  string offerId;
         *  to.Send(out offerId, "Test trade offer");
         *
         *  Console.WriteLine("Offer ID : {0}", offerId);
         *
         *  AcceptMobileTradeConfirmation(offerId);
         * }*/
        ////////////////////////////////////////////////////////////////////
        public void AcceptMobileTradeConfirmation(string offerId)
        {
            steamGuardAccount.Session.SteamLogin       = steamWeb.Token;
            steamGuardAccount.Session.SteamLoginSecure = steamWeb.TokenSecure;
            try
            {
                foreach (var confirmation in steamGuardAccount.FetchConfirmations())
                {
                    if (confirmation.ConfType == Confirmation.ConfirmationType.Trade)
                    {
                        long confID = steamGuardAccount.GetConfirmationTradeOfferID(confirmation);
                        if (confID == long.Parse(offerId) && steamGuardAccount.AcceptConfirmation(confirmation))
                        {
                            Console.WriteLine("Confirmed {0}. (Confirmation ID #{1})", confirmation.Description, confirmation.ID);
                        }
                    }
                }
            }
            catch (SteamGuardAccount.WGTokenInvalidException)
            {
                Console.WriteLine("Invalid session when trying to fetch trade confirmations.");
            }
        }
예제 #10
0
        static void processConfirmations(SteamGuardAccount account)
        {
            if (Verbose)
            {
                Console.WriteLine("Refeshing Session...");
            }
            if (account.RefreshSession())
            {
                if (Verbose)
                {
                    Console.WriteLine("Session refreshed");
                }
                Manifest.SaveAccount(account, Manifest.Encrypted);
            }
            else
            {
                if (Verbose)
                {
                    Console.WriteLine("Failed to refresh session");
                }
                Console.WriteLine("Your Steam credentials have expired. For trade and market confirmations to work properly, please login again.");
                string username = account.AccountName;
                Console.WriteLine($"Username: {username}");
                Console.Write("Password: "******"Logging in {username}... ");
                LoginResult loginResult = login.DoLogin();
                if (loginResult == LoginResult.Need2FA && !string.IsNullOrEmpty(account.SharedSecret))
                {
                    // if we need a 2fa code, and we can generate it, generate a 2fa code and log in.
                    if (Verbose)
                    {
                        Console.WriteLine(loginResult);
                    }
                    TimeAligner.AlignTime();
                    login.TwoFactorCode = account.GenerateSteamGuardCode();
                    if (Verbose)
                    {
                        Console.Write($"Logging in {username}... ");
                    }
                    loginResult = login.DoLogin();
                }
                Console.WriteLine(loginResult);
                if (loginResult == LoginResult.LoginOkay)
                {
                    account.Session = login.Session;
                }

                if (account.RefreshSession())
                {
                    if (Verbose)
                    {
                        Console.WriteLine("Session refreshed");
                    }
                    Manifest.SaveAccount(account, Manifest.Encrypted);
                }
                else
                {
                    Console.WriteLine("Failed to refresh session, aborting...");
                    return;
                }
            }
            Console.WriteLine("Retrieving trade confirmations...");
            var tradesTask = account.FetchConfirmationsAsync();

            tradesTask.Wait();
            var trades       = tradesTask.Result;
            var tradeActions = new TradeAction[trades.Length];

            for (var i = 0; i < tradeActions.Length; i++)
            {
                tradeActions[i] = TradeAction.Ignore;
            }
            if (trades.Length == 0)
            {
                Console.WriteLine($"No trade confirmations for {account.AccountName}.");
                return;
            }
            var selected      = 0;
            var colorAccept   = ConsoleColor.Green;
            var colorDeny     = ConsoleColor.Red;
            var colorIgnore   = ConsoleColor.Gray;
            var colorSelected = ConsoleColor.Yellow;
            var confirm       = false;

            do
            {
                Console.Clear();
                if (selected >= trades.Length)
                {
                    selected = trades.Length - 1;
                }
                else if (selected < 0)
                {
                    selected = 0;
                }
                Console.ResetColor();
                Console.WriteLine($"Trade confirmations for {account.AccountName}...");
                Console.WriteLine("No action will be made without your confirmation.");
                Console.WriteLine("[a]ccept   [d]eny   [i]gnore  [enter] Confirm  [q]uit");                 // accept = 1, deny = 0, ignore = -1
                Console.WriteLine();

                for (var t = 0; t < trades.Length; t++)
                {
                    ConsoleColor itemColor;
                    switch (tradeActions[t])
                    {
                    case TradeAction.Accept:
                        itemColor = colorAccept;
                        break;

                    case TradeAction.Deny:
                        itemColor = colorDeny;
                        break;

                    case TradeAction.Ignore:
                        itemColor = colorIgnore;
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }

                    Console.ForegroundColor = t == selected ? colorSelected : itemColor;

                    Console.WriteLine($"  [{t}] [{tradeActions[t]}] {trades[t].Description}");
                }
                var key = Console.ReadKey();
                switch (key.Key)
                {
                case ConsoleKey.UpArrow:
                case ConsoleKey.W:
                    selected--;
                    break;

                case ConsoleKey.DownArrow:
                case ConsoleKey.S:
                    selected++;
                    break;

                case ConsoleKey.A:
                    tradeActions[selected] = TradeAction.Accept;
                    break;

                case ConsoleKey.D:
                    tradeActions[selected] = TradeAction.Deny;
                    break;

                case ConsoleKey.I:
                    tradeActions[selected] = TradeAction.Ignore;
                    break;

                case ConsoleKey.Enter:
                    confirm = true;
                    break;

                case ConsoleKey.Escape:
                case ConsoleKey.Q:
                    Console.ResetColor();
                    Console.WriteLine("Quitting...");
                    return;

                default:
                    break;
                }
            } while (!confirm);
            Console.ResetColor();
            Console.WriteLine();
            Console.WriteLine("Processing...");
            for (var t = 0; t < trades.Length; t++)
            {
                bool success = false;
                switch (tradeActions[t])
                {
                case TradeAction.Accept:
                    if (Verbose)
                    {
                        Console.Write($"Accepting {trades[t].Description}...");
                    }
                    success = account.AcceptConfirmation(trades[t]);
                    break;

                case TradeAction.Deny:
                    if (Verbose)
                    {
                        Console.Write($"Denying {trades[t].Description}...");
                    }
                    success = account.AcceptConfirmation(trades[t]);
                    break;

                case TradeAction.Ignore:
                    if (Verbose)
                    {
                        Console.Write($"Ignoring {trades[t].Description}...");
                    }
                    success = true;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                if (Verbose)
                {
                    Console.WriteLine(success);
                }
            }
            Console.WriteLine("Done.");
        }
예제 #11
0
        static void processConfirmations(SteamGuardAccount account)
        {
            Utils.Verbose("Refeshing Session...");
            if (account.RefreshSession())
            {
                Utils.Verbose("Session refreshed");
                Manifest.SaveAccount(account, Manifest.Encrypted);
            }
            else
            {
                Utils.Verbose("Failed to refresh session, prompting user...");
                if (!promptRefreshSession(account))
                {
                    Console.WriteLine("Failed to refresh session, aborting...");
                }
            }
            Console.WriteLine("Retrieving trade confirmations...");
            var tradesTask = account.FetchConfirmationsAsync();

            tradesTask.Wait();
            var trades       = tradesTask.Result;
            var tradeActions = new TradeAction[trades.Length];

            for (var i = 0; i < tradeActions.Length; i++)
            {
                tradeActions[i] = TradeAction.Ignore;
            }
            if (trades.Length == 0)
            {
                Console.WriteLine($"No trade confirmations for {account.AccountName}.");
                return;
            }
            var selected      = 0;
            var colorAccept   = ConsoleColor.Green;
            var colorDeny     = ConsoleColor.Red;
            var colorIgnore   = ConsoleColor.Gray;
            var colorSelected = ConsoleColor.Yellow;
            var confirm       = false;

            do
            {
                Console.Clear();
                if (selected >= trades.Length)
                {
                    selected = trades.Length - 1;
                }
                else if (selected < 0)
                {
                    selected = 0;
                }
                Console.ResetColor();
                Console.WriteLine($"Trade confirmations for {account.AccountName}...");
                Console.WriteLine("No action will be made without your confirmation.");
                Console.WriteLine("[a]ccept   [d]eny   [i]gnore  [enter] Confirm  [q]uit");                 // accept = 1, deny = 0, ignore = -1
                Console.WriteLine();

                for (var t = 0; t < trades.Length; t++)
                {
                    ConsoleColor itemColor;
                    switch (tradeActions[t])
                    {
                    case TradeAction.Accept:
                        itemColor = colorAccept;
                        break;

                    case TradeAction.Deny:
                        itemColor = colorDeny;
                        break;

                    case TradeAction.Ignore:
                        itemColor = colorIgnore;
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }

                    Console.ForegroundColor = t == selected ? colorSelected : itemColor;

                    Console.WriteLine($"  [{t}] [{tradeActions[t]}] {trades[t].ConfType} {trades[t].Creator} {trades[t].Description}");
                }
                var key = Console.ReadKey();
                switch (key.Key)
                {
                case ConsoleKey.UpArrow:
                case ConsoleKey.W:
                    selected--;
                    break;

                case ConsoleKey.DownArrow:
                case ConsoleKey.S:
                    selected++;
                    break;

                case ConsoleKey.A:
                    tradeActions[selected] = TradeAction.Accept;
                    break;

                case ConsoleKey.D:
                    tradeActions[selected] = TradeAction.Deny;
                    break;

                case ConsoleKey.I:
                    tradeActions[selected] = TradeAction.Ignore;
                    break;

                case ConsoleKey.Enter:
                    confirm = true;
                    break;

                case ConsoleKey.Escape:
                case ConsoleKey.Q:
                    Console.ResetColor();
                    Console.WriteLine("Quitting...");
                    return;

                default:
                    break;
                }
            } while (!confirm);
            Console.ResetColor();
            Console.WriteLine();
            Console.WriteLine("Processing...");
            for (var t = 0; t < trades.Length; t++)
            {
                bool success = false;
                switch (tradeActions[t])
                {
                case TradeAction.Accept:
                    if (Verbose)
                    {
                        Console.Write($"Accepting {trades[t].ConfType} {trades[t].Creator} {trades[t].Description}...");
                    }
                    success = account.AcceptConfirmation(trades[t]);
                    break;

                case TradeAction.Deny:
                    if (Verbose)
                    {
                        Console.Write($"Denying {trades[t].ConfType} {trades[t].Creator} {trades[t].Description}...");
                    }
                    success = account.DenyConfirmation(trades[t]);
                    break;

                case TradeAction.Ignore:
                    if (Verbose)
                    {
                        Console.Write($"Ignoring {trades[t].ConfType} {trades[t].Creator} {trades[t].Description}...");
                    }
                    success = true;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                Utils.Verbose(success);
            }
            Console.WriteLine("Done.");
        }