Exemplo n.º 1
0
        void OnLoggedOn(SteamUser.LoggedOnCallback callback)
        {
            if (callback.Result != EResult.OK)
            {
                // logon failed (password incorrect, steamguard enabled, etc)
                // an EResult of AccountLogonDenied means the account has SteamGuard enabled and an email containing the authcode was sent
                // in that case, you would get the auth code from the email and provide it in the LogOnDetails
                ModernDialog.ShowMessage("登陆至Steam失败", callback.Result.ToString(), MessageBoxButton.OK);
                //等待修改为重新登陆(手动输入Email验证码)
                return;
            }
            // we've logged into the account
            // now we need to inform the steam server that we're playing dota (in order to receive GC messages)
            // steamkit doesn't expose the "play game" message through any handler, so we'll just send the message manually
            var playGame = new ClientMsgProtobuf <CMsgClientGamesPlayed>(EMsg.ClientGamesPlayed);

            playGame.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed
            {
                game_id = new GameID(APPID), // or game_id = APPID,
            });
            // send it off
            // notice here we're sending this message directly using the SteamClient
            steamClient.Send(playGame);
            // delay a little to give steam some time to establish a GC connection to us
            Thread.Sleep(5000);
            // inform the dota GC that we want a session
            var clientHello = new ClientGCMsgProtobuf <CMsgClientHello>((uint)EGCBaseClientMsg.k_EMsgGCClientHello);

            clientHello.Body.engine = ESourceEngine.k_ESE_Source2;
            steamGameCoordinator.Send(clientHello, APPID);
        }
Exemplo n.º 2
0
 private void OnLoggedIn(SteamUser.LoggedOnCallback callback)
 {
     if (callback.Result == EResult.OK)
     {
         Machine.Trigger(Event.CONNECTED_TO_STEAM);
     }
 }
        void OnLoggedOn(SteamUser.LoggedOnCallback callback)
        {
            if (callback.Result != EResult.OK)
            {
                if (callback.Result == EResult.AccountLogonDenied)
                {
                    // if we recieve AccountLogonDenied or one of it's flavors (AccountLogonDeniedNoMailSent, etc)
                    // then the account we're logging into is SteamGuard protected
                    // see sample 5 for how SteamGuard can be handled

                    Console.WriteLine("Unable to logon to Steam: This account is SteamGuard protected.");

                    _isRunning = false;
                    return;
                }

                Console.WriteLine("Unable to logon to Steam: {0} / {1}", callback.Result, callback.ExtendedResult);

                _isRunning = false;
                return;
            }

            Console.WriteLine("Successfully logged on!");

            if (_cmd == Command.GetBot64Id)
            {
                _bot64Id       = _steamClient.SteamID.ConvertToUInt64().ToString();
                _isMessageSent = true;
            }
            // at this point, we'd be able to perform actions on
            // for this sample we wait for other callbacks to perform logic
        }
Exemplo n.º 4
0
        void OnLoggedOn(SteamUser.LoggedOnCallback callback)
        {
            if (callback.Result != EResult.OK)
            {
                Console.WriteLine("Unable to logon to Steam: {0}", callback.Result);

                gotMatch = true;
                return;
            }

            Console.WriteLine("Logged in! Launching DOTA...");



            var playGame = new ClientMsgProtobuf <CMsgClientGamesPlayed>(EMsg.ClientGamesPlayed);

            playGame.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed
            {
                game_id = new GameID(APPID),
            });


            client.Send(playGame);

            Thread.Sleep(5000);

            var clientHello = new ClientGCMsgProtobuf <CMsgClientHello>((uint)EGCBaseClientMsg.k_EMsgGCClientHello);

            clientHello.Body.engine = ESourceEngine.k_ESE_Source2;
            gameCoordinator.Send(clientHello, APPID);
        }
Exemplo n.º 5
0
        private void OnLoggedOn(SteamUser.LoggedOnCallback obj)
        {
            logger.Info($"Log on to Steam with bot {BotName} is successful.");

            var playGame = new ClientMsgProtobuf <CMsgClientGamesPlayed>(EMsg.ClientGamesPlayed);

            playGame.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed
            {
                game_id = new GameID(Dota2AppId)
            });

            logger.Info("Hello message is sending...");
            steamClient.Send(playGame);

            logger.Info("Connecting to Game Coordinator...");
            Thread.Sleep(5000);
            logger.Info("Connection to Game Coordinator is successful (just waiting 5 seconds).");

            var clientHello = new ClientGCMsgProtobuf <CMsgClientHello>((uint)EGCBaseClientMsg.k_EMsgGCClientHello);

            clientHello.Body.engine = ESourceEngine.k_ESE_Source2;

            logger.Info("Sending Hello message...");
            gameCoordinator.Send(clientHello, Dota2AppId);
        }
Exemplo n.º 6
0
        private void onLoggedOn(SteamUser.LoggedOnCallback callback)
        {
            bool isSteamGuard = callback.Result == EResult.AccountLogonDenied;

            this.is2FA = callback.Result == EResult.AccountLoginDeniedNeedTwoFactor;

            if (isSteamGuard || this.is2FA)
            {
                if (this.is2FA)
                {
                    this.setMessageText("Check your authenticator app: ");
                }
                else
                {
                    this.setMessageText("Sent to the email at " + callback.EmailDomain);
                }
                this.SteamGuardInput = true;
            }
            else if (callback.Result != EResult.OK)
            {
                this.setMessageText("Unable to logon: " + callback.Result + " / " + callback.ExtendedResult);
            }
            else
            {
                this.setMessageText("Login success");
                this.isLoginSuccess = true;
                this.Dispose();
            }
        }
Exemplo n.º 7
0
        private void OnLoggedOn(SteamUser.LoggedOnCallback obj)
        {
            if (obj.Result != EResult.OK)
            {
                IsSuccess = false;
                IsDone    = true;
                Logger.Error($"Failed logging in! Result: {obj.Result} / {obj.ExtendedResult}");
                return;
            }

            Logger.Log("Logged on!");
            LastActionTime = DateTime.Now;

            // Change name
            Friends.SetPersonaName("User344 (vk.com/moveax)");

            // Add CS:GO to account
            var clientCertRequest = new ClientMsgProtobuf <CMsgClientNetworkingCertRequest>(EMsg.ClientNetworkingCertRequest);

            clientCertRequest.Body.key_data = new byte[] { };
            clientCertRequest.Body.app_id   = 730;
            Client.Send(clientCertRequest);

            PlayGame(730);
        }
Exemplo n.º 8
0
        void OnLoggedOn(SteamUser.LoggedOnCallback cb)
        {
            switch (cb.Result)
            {
            case EResult.AccountLogonDenied:
            case EResult.AccountLoginDeniedNeedTwoFactor:
            case EResult.InvalidPassword:
            {
                OnAccountLogonDenied(cb);
                return;
            }

            case EResult.OK:
            {
                OnAccountLogonSuccess(cb);
                return;
            }

            default:
            {
                Log.WriteLine("Unable to logon to Steam: {0}", cb.Result.ExtendedString());
                return;
            }
            }
        }
Exemplo n.º 9
0
        static void onLoggedOn(SteamUser.LoggedOnCallback callback)
        {
            bool isSteamGuard = callback.Result == EResult.AccountLogonDenied;
            bool is2FA        = callback.Result == EResult.AccountLoginDeniedNeedTwoFactor;

            if (isSteamGuard || is2FA)
            {
                Console.WriteLine("This account is SteamGuard protected!");

                if (is2FA)
                {
                    Console.Write("Please enter 2 factor auth code form phone app: ");
                    twoFactorCode = Console.ReadLine();
                }
                else
                {
                    Console.Write("Please enter auth code sent to {0} here:", callback.EmailDomain);
                    authCode = Console.ReadLine();
                }

                return;
            }

            if (callback.Result != EResult.OK)
            {
                Console.WriteLine("Unable to logon to Steam: {0} / {1}", callback.Result, callback.ExtendedResult);

                isRunning = false;
                return;
            }


            Console.WriteLine("{0}, succesfully logged in!", user);
        }
Exemplo n.º 10
0
        static void OnLoggedOn(SteamUser.LoggedOnCallback callback)
        {
            if (callback.Result != EResult.OK)
            {
                if (callback.Result == EResult.AccountLogonDenied)
                {
                    Console.WriteLine("Unable to logon to Steam: This account is SteamGuard protected.");

                    AuthForm authDialog = new AuthForm();
                    authDialog.ShowDialog();

                    if (authDialog.DialogResult == DialogResult.OK)
                    {
                        authCode = authDialog.AuthValue;
                    }
                    else
                    {
                        isRunning = false;
                    }
                    return;
                }

                Console.WriteLine("Unable to logon to Steam: {0} / {1}", callback.Result, callback.ExtendedResult);
                alert("Unable to logon to Steam: " + callback.Result + " / " + callback.ExtendedResult);
                isRunning = false;
                return;
            }

            Console.WriteLine("Successfully logged on!");
        }
Exemplo n.º 11
0
        void OnAccountLogonDenied(SteamUser.LoggedOnCallback cb)
        {
            logon_state = LogonState.LoggedOff;

            Log.WriteLine("OnAccountLogonDenied: {0}", cb.Result.ExtendedString());

            switch (cb.Result)
            {
            case EResult.AccountLoginDeniedNeedTwoFactor:
            {
                Log.WriteLine("Needs twofactor code...");
                logon_needs = LogonNeeds.TwoFactor;
                break;
            }

            case EResult.AccountLogonDenied:
            {
                Log.WriteLine("Needs steamguard code...");
                logon_needs = LogonNeeds.SteamGuard;
                break;
            }
            }

            var b = new Core.Util.Buffer();

            b.SetAlignment(4);

            b.Write((uint)cb.Result);
            b.WriteBool(false);

            Instance.PostCallback(102, b);
        }
Exemplo n.º 12
0
 private void OnLoggedOn(SteamUser.LoggedOnCallback obj)
 {
     if (obj.Result != EResult.OK)
     {
         _logger?.LogError($"Invalid login ({_credentials.Username}): {obj.Result} / {obj.ExtendedResult}");
     }
 }
Exemplo n.º 13
0
        void OnLoggedOn(SteamUser.LoggedOnCallback callback)
        {
            bool isSteamGuard = callback.Result == EResult.AccountLogonDenied;
            bool is2FA        = callback.Result == EResult.AccountLoginDeniedNeedTwoFactor;

            if (isSteamGuard || is2FA)
            {
                Console.WriteLine("This account is SteamGuard protected!");

                if (is2FA)
                {
                    Console.Write("Please enter your 2 factor auth code from your authenticator app: ");

                    _twoFactorAuth = _getCode();
                }
                else
                {
                    Console.Write("Please enter the auth code sent to the email at {0}: ", callback.EmailDomain);

                    _authCode = _getCode();
                    Console.Write(_authCode + "\n");
                }
                //<span style="font-size:24px;color:#66c0f4;font-family:Arial,Helvetica,sans-serif;font-weight:bold;"> 8DGXG </span>
                return;
            }

            if (callback.Result != EResult.OK)
            {
                Console.WriteLine("Unable to logon to Steam: {0} / {1}", callback.Result, callback.ExtendedResult);
                return;
            }
            _userNonce = callback.WebAPIUserNonce;
            Console.WriteLine("Successfully logged on!");
        }
Exemplo n.º 14
0
        private void OnLoggedOn(SteamUser.LoggedOnCallback callback)
        {
            var isSteamGuard = callback.Result == EResult.AccountLogonDenied;
            var is2FA        = callback.Result == EResult.AccountLoginDeniedNeedTwoFactor;

            if (isSteamGuard || is2FA)
            {
                Console.WriteLine("This account is SteamGuard protected!");

                if (is2FA)
                {
                    Console.Write("Please enter your two-factor authentication code: ");
                    _twoFactorCode = Console.ReadLine();
                }
                else
                {
                    Console.Write("Please enter the authentication code sent to the email at {0}: ", callback.EmailDomain);
                    _authCode = Console.ReadLine();
                }

                return;
            }

            if (callback.Result != EResult.OK)
            {
                Console.WriteLine("Unable to logon to Steam: {0} / {1}", callback.Result, callback.ExtendedResult);
                _steamNerd.Disconnect();
                return;
            }

            Console.WriteLine("Logged in!");
            _password = "";
        }
Exemplo n.º 15
0
 //We give it the LoggedOnCallback class, named callback. This is so that we can interact with the callback. Performing specific actions.
 static void OnLoggedOn(SteamUser.LoggedOnCallback callback)
 {
     //Now we check if our log on request was denied
     if (callback.Result == EResult.AccountLogonDenied) //Quick thing, it is supposed to be '==' not '!='
     {
         //Since it was denied, the account must have SteamGuard protection on.
         Console.WriteLine("This account is SteamGuard protected.");
         //We ask the user for the authentication code sent to the email when steam detects an account being accessed from something it doesn't recognize, and inform them of the EMail domain
         //Steam sent the code to
         Console.Write("Please enter the auth code sent to the email at {0}: ", callback.EmailDomain);
         //Now we create a string to hold the authcode
         //Now, what do we do when we need input from the user? Console.ReadLine()
         authCode = Console.ReadLine();
         //Exit the function
         //Create UpdateMachineAuthCallback
         return;
     }
     if (callback.Result != EResult.OK)
     {
         //We inform the user that we couldn't logon to steam, and the reason why.
         Console.WriteLine("Unable to log in to Steam: {0}\n", callback.Result);
         //Since we couldn't log on, we exit the loop.
         isRunning = false;
         //Exit the function
         return;
     }
     //Now we can do things! That is the end of this tutorial, however. Next tutorial we will handle SteamGuard so we can log on into a secure account.
     Console.WriteLine("{0} successfully logged in!", user);
 }
Exemplo n.º 16
0
        private void OnSteamUserLoggedOn(SteamUser.LoggedOnCallback callback)
        {
            if (callback.Result == EResult.AccountLogonDenied)
            {
                //Account is Steam Guarded, but doesn't need 2FA, this is a blocking call, when it's done, we have completed this.
                RequestEmailAuthenticationCode();
                //now disconnect
                Disconnect();
                //and reconnect with the needed info.
                Login(m_SteamUserName, m_SteamPassword, SteamManager.SteamAPIKey);
            }
            else if (callback.Result == EResult.AccountLoginDeniedNeedTwoFactor)
            {
                //Account is Steam Guarded, and uses 2FA, this is a blocking call, when it's done, we have completed this.
                RequestTwoFactorAuthenticationCode();
                //now disconnect
                Disconnect();
                //and reconnect with the needed info.
                Login(m_SteamUserName, m_SteamPassword, SteamManager.SteamAPIKey);
            }
            else if (callback.Result != EResult.OK)
            {
                OnLogonFailure?.Invoke(this, string.Format("Unable to logon to Steam: {0} / {1}", callback.Result, callback.ExtendedResult));

                Disconnect();
            }
            else
            {
                OnLogonSuccess?.Invoke(this, string.Format("Successfully logged on!"));
            }
        }
Exemplo n.º 17
0
        void OnLoggedOn(SteamUser.LoggedOnCallback callback)
        {
            if (callback.Result != EResult.OK)
            {
                if (callback.Result == EResult.RateLimitExceeded || callback.Result == EResult.TryAnotherCM)
                {
                    // fingers crossed
                    nextConnectDelayed = true;
                }

                Log.WriteWarn("Steam", "Unable to logon to Steam3: {0} / {1}", callback.Result, callback.ExtendedResult);

                IRC.Instance.SendEmoteToTag("steam-logon", "Unable to logon to Steam: {0} / {1}", callback.Result, callback.ExtendedResult);
                return;
            }

            loggedOn           = true;
            nextConnectDelayed = false;

            CellID = callback.CellID;

            Log.WriteInfo("Steam", "Logged onto Steam3!");

            IRC.Instance.SendEmoteToTag("steam", "Logged on to Steam! Server time: {0}", callback.ServerTime);
            ClientMsgProtobuf <CMsgClientUIMode> request = new ClientMsgProtobuf <CMsgClientUIMode>(EMsg.ClientCurrentUIMode)
            {
                Body = { chat_mode = 2 }
            };

            Client.Send(request);
            JobManager.ForceRun <GameSessionJob>();
        }
Exemplo n.º 18
0
        private static void OnLoggedOn(SteamUser.LoggedOnCallback obj)
        {
            var isSteamGuard = obj.Result == EResult.AccountLogonDenied;
            var is2Fa        = obj.Result == EResult.AccountLoginDeniedNeedTwoFactor;

            if (isSteamGuard || is2Fa)
            {
                Console.WriteLine("This account is SteamGuard protected!");
                if (is2Fa)
                {
                    Console.Write("Please enter your 2 factor auth code from your authenticator app: ");
                    _twoFactorAuth = Console.ReadLine();
                }
                else
                {
                    Console.Write("Please enter the auth code sent to the email at {0}: ", obj.EmailDomain);
                    _authCode = Console.ReadLine();
                }

                return;
            }

            if (obj.Result != EResult.OK)
            {
                Console.WriteLine("Unable to logon to Steam: {0} / {1}", obj.Result, obj.ExtendedResult);
                _isRunning = false;
                return;
            }

            Console.WriteLine("Successfully logged into steam with id {0}", _username);

            //SteamUser.LogOff();
        }
Exemplo n.º 19
0
        static void OnLoggedOn(SteamUser.LoggedOnCallback callback)
        {
            bool isSteamGuard = callback.Result == EResult.AccountLogonDenied;
            bool is2FA        = callback.Result == EResult.AccountLoginDeniedNeedTwoFactor;

            if (isSteamGuard || is2FA)
            {
                Console.WriteLine("This account is SteamGuard protected!");

                if (is2FA)
                {
                    Console.Write("Please enter your 2 factor auth code from your authenticator app: ");
                    twoFactorAuth = Console.ReadLine();
                }
                else
                {
                    Console.Write("Please enter the auth code sent to the email at {0}: ", callback.EmailDomain);
                    authCode = Console.ReadLine();
                }

                return;
            }

            if (callback.Result != EResult.OK)
            {
                Console.WriteLine("Unable to logon to Steam: {0} / {1}", callback.Result, callback.ExtendedResult);

                isRunning = false;
                return;
            }

            Console.WriteLine("Successfully logged on!");
            FullyLoggedIn(callback);
        }
Exemplo n.º 20
0
        static void OnLoggedOn(SteamUser.LoggedOnCallback callback)
        {
            if (callback.Result != EResult.OK)
            {
                if (callback.Result == EResult.AccountLogonDenied)
                {
                    // if we recieve AccountLogonDenied or one of it's flavors (AccountLogonDeniedNoMailSent, etc)
                    // then the account we're logging into is SteamGuard protected
                    // see sample 5 for how SteamGuard can be handled

                    Console.WriteLine("Unable to logon to Steam: This account is SteamGuard protected.");

                    isRunning = false;
                    return;
                }

                Console.WriteLine("Unable to logon to Steam: {0} / {1}", callback.Result, callback.ExtendedResult);

                isRunning = false;
                return;
            }

            Console.WriteLine("Successfully logged on!");

            // at this point, we'd be able to perform actions on Steam

            // for this sample we'll just log off
            steamUser.LogOff();
        }
Exemplo n.º 21
0
        /// <summary>
        /// OnLoggedOn callback
        /// Fires when steam logs on successfully
        /// </summary>
        /// <param name="callback">LoggedOnCallback</param>
        private void OnLoggedOn(SteamUser.LoggedOnCallback callback)
        {
            if (callback.Result == EResult.AccountLoginDeniedNeedTwoFactor || callback.Result == EResult.TwoFactorCodeMismatch)
            {
                mLog.Write(Log.LogLevel.Info, "Fetching Steam Guard code");
                mSteam.logOnDetails.TwoFactorCode = mSteam.Auth.GetSteamGuardCode();
                return;
            }

            if (callback.Result != EResult.OK)
            {
                if (callback.Result == EResult.ServiceUnavailable)
                {
                    mLog.Write(Log.LogLevel.Error, $"Steam is down, waiting for 20 seconds - {callback.Result}");
                    Thread.Sleep(20000);
                    return;
                }

                mLog.Write(Log.LogLevel.Error, $"Unable to login to Steam - {callback.Result}");
                Thread.Sleep(2500);
                return;
            }

            mLog.Write(Log.LogLevel.Info, "Logged in! Authenticating...", false);
            mSteam.nounce = callback.WebAPIUserNonce;
        }
Exemplo n.º 22
0
        static void OnLoggedOn(SteamUser.LoggedOnCallback callback)
        {
            if (callback.Result == EResult.AccountLogonDeniedNeedTwoFactorCode)
            {
                Console.WriteLine("Please Enter In Your Two Factor Auth Code.\n");
                twofactor = Console.ReadLine();
                return;
            }
            if (callback.Result == EResult.AccountLogonDenied)
            {
                Console.WriteLine("Account is steam guard Protected.");

                Console.Write("Please Enter In The Auth Code Sent To The Email At {0}: ", callback.EmailDomain);

                authcode = Console.ReadLine();

                return;
            }
            if (callback.Result != EResult.OK)
            {
                Console.WriteLine("Unable to connect to Steam account: {0}", callback.Result);
                isRunning = false;
                return;
            }
            Console.WriteLine("Succesfully logged in: {0}", callback.Result);
        }
Exemplo n.º 23
0
        static void OnLoggedOn(SteamUser.LoggedOnCallback callback)
        {
            if (callback.Result != EResult.OK)
            {
                if (callback.Result == EResult.AccountLogonDenied)
                {
                    // if we recieve AccountLogonDenied or one of it's flavors (AccountLogonDeniedNoMailSent, etc)
                    // then the account we're logging into is SteamGuard protected
                    // see sample 5 for how SteamGuard can be handled

                    Console.WriteLine("Unable to logon to Steam: This account is SteamGuard protected.");

                    isRunning = false;
                    return;
                }

                Console.WriteLine("Unable to logon to Steam: {0} / {1}", callback.Result, callback.ExtendedResult);

                isRunning = false;
                return;
            }

            // save the current cellid somewhere. if we lose our saved server list, we can use this when retrieving
            // servers from the Steam Directory.
            File.WriteAllText("cellid.txt", callback.CellID.ToString());

            Console.WriteLine("Successfully logged on! Press Ctrl+C to log off...");
        }
Exemplo n.º 24
0
 private void OnLoggedOn(SteamUser.LoggedOnCallback callback)
 {
     if (this.Visible == false)
     {
         return;
     }
     Program.steam.isRunning = false;
     if (callback.Result != EResult.OK)
     {
         if (Program.isMinimized)
         {
             Utils.ShowNotify(Program.notifyIcon, "The connection of your Steam account has been lost.");
         }
         else
         {
             MessageBox.Show("The connection of your Steam account has been lost.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         Program.steamAvailable = false;
         IniModel.DeleteSteamLoginKey();
         return;
     }
     else
     {
         Program.steamAvailable = true;
     }
 }
Exemplo n.º 25
0
 private void OnLoggedOn(SteamUser.LoggedOnCallback obj)
 {
     if (obj.Result == EResult.OK)
     {
         UpdateStatus(DotaClientStatus.Normal, "Steam: Logged on.");
         LoggedIn = true;
     }
     else
     {
         LoggedIn = false;
         if (parameters.relogin)
         {
             UpdateStatus(DotaClientStatus.Warning, "Steam: Login Failed. Retrying...");
             Thread.Sleep(1000);
             user.LogOn(new SteamUser.LogOnDetails {
                 Username = username,
                 Password = password,
             });
         }
         else
         {
             UpdateStatus(DotaClientStatus.Fatal, "Steam: Login Failed.");
         }
     }
 }
Exemplo n.º 26
0
        // called when the client successfully (or unsuccessfully) logs onto an account
        void OnLoggedOn(SteamUser.LoggedOnCallback callback)
        {
            if (callback.Result != EResult.OK)
            {
                // logon failed (password incorrect, steamguard enabled, etc)
                // an EResult of AccountLogonDenied means the account has SteamGuard enabled and an email containing the authcode was sent
                // in that case, you would get the auth code from the email and provide it in the LogOnDetails

                Console.WriteLine("Unable to logon to Steam: {0}", callback.Result);

                gotMatch = true; // we didn't actually get the match details, but we need to jump out of the callback loop
                return;
            }

            Console.WriteLine("Logged in! Launching DOTA...");

            // we've logged into the account
            // now we need to inform the steam server that we're playing dota (in order to receive GC messages)

            // steamkit doesn't expose the "play game" message through any handler, so we'll just send the message manually
            var playGame = new ClientMsgProtobuf <CMsgClientGamesPlayed>(EMsg.ClientGamesPlayed);

            playGame.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed
            {
                game_id = new GameID(APPID),   // or game_id = APPID,
            });

            // send it off
            // notice here we're sending this message directly using the SteamClient
            client.Send(playGame);
        }
Exemplo n.º 27
0
        private static void OnLoggedOn(SteamUser.LoggedOnCallback callback)
        {
            if (callback.Result == EResult.AccountLoginDeniedNeedTwoFactor)
            {
                Console.Write("Please enter your 2 factor auth code from your authenticator app: ");
                twoFactorAuth = Console.ReadLine();
                return;
            }

            if (callback.Result == EResult.AccountLogonDenied)
            {
                Console.Write("Please enter the auth code sent to the email at {0}: ", callback.EmailDomain);
                authCode = Console.ReadLine();
                return;
            }

            if (callback.Result != EResult.OK)
            {
                Log($"Failed to login: {callback.Result}");

                Thread.Sleep(TimeSpan.FromSeconds(2));

                return;
            }

            Log($"Logged in, current valve time is {callback.ServerTime} UTC");
        }
Exemplo n.º 28
0
        private void LogOnCallback(SteamUser.LoggedOnCallback loggedOn)
        {
            bool isSteamGuard = loggedOn.Result == EResult.AccountLogonDenied;
            bool is2FA        = loggedOn.Result == EResult.AccountLoginDeniedNeedTwoFactor;

            // bool isLoginKey = ContentDownloader.Config.RememberPassword && logonDetails.LoginKey != null && loggedOn.Result == EResult.InvalidPassword;

            if (isSteamGuard || is2FA)
            {
                bExpectingDisconnectRemote = true;
                Abort(false);

                // if ( !isLoginKey )
                // {
                //     Console.WriteLine( "This account is protected by Steam Guard." );
                // }

                if (is2FA)
                {
                    Console.Write("Please enter your 2 factor auth code from your authenticator app: ");
                    logonDetails.TwoFactorCode = Console.ReadLine();
                }
                else
                {
                    Console.Write("Please enter the authentication code sent to your email address: ");
                    logonDetails.AuthCode = Console.ReadLine();
                }

                Console.Write("Retrying Steam3 connection...");
                Connect();

                return;
            }
            else if (loggedOn.Result == EResult.ServiceUnavailable)
            {
                Console.WriteLine("Unable to login to Steam3: {0}", loggedOn.Result);
                Abort(false);

                return;
            }
            else if (loggedOn.Result != EResult.OK)
            {
                Console.WriteLine("Unable to login to Steam3: {0}", loggedOn.Result);
                Abort();

                return;
            }

            Console.WriteLine(" Done!");

            this.seq++;
            credentials.LoggedOn = true;

            // if ( ContentDownloader.Config.CellID == 0 )
            // {
            //     Console.WriteLine( "Using Steam3 suggested CellID: " + loggedOn.CellID );
            //     ContentDownloader.Config.CellID = ( int )loggedOn.CellID;
            // }
        }
Exemplo n.º 29
0
        async void OnLoggedOn(SteamUser.LoggedOnCallback callback)
        {
            if (callback == null)
            {
                return;
            }

            switch (callback.Result)
            {
            case EResult.TwoFactorCodeMismatch:
            case EResult.AccountLoginDeniedNeedTwoFactor:
            case EResult.AccountLogonDenied:
                form.AddLog("[ERROR] SteamGuard needed for this account!");
                return;

            case EResult.InvalidPassword:
                form.AddLog("[ERROR] Unable to login to Steam: " + callback.Result);
                return;

            case EResult.OK:
                form.AddLog("Successfully connected!");

                isConnected = true;

                if (steamFriends.GetPersonaState() != EPersonaState.Online)
                {
                    steamFriends.SetPersonaState(EPersonaState.Online);
                }

                var gamePlayed = new ClientMsgProtobuf <CMsgClientGamesPlayed>(EMsg.ClientGamesPlayed);
                gamePlayed.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed
                {
                    game_id = new GameID(CSGO_APPID)
                });

                steamClient.Send(gamePlayed);

                Thread.Sleep(TimeSpan.FromSeconds(5));

                //Send ClientToGC GCClientHello to valve servers
                var clientHello = new ClientGCMsgProtobuf <CMsgClientHello>((uint)EGCBaseClientMsg.k_EMsgGCClientHello);
                clientHello.Body.version             = CSGO_VERSION;
                clientHello.Body.client_session_need = 0;
                clientHello.Body.client_launcher     = 0;
                steamGameCoordinator.Send(clientHello, CSGO_APPID);

                var clientCertRequest = new ClientMsgProtobuf <CMsgClientNetworkingCertRequest>(EMsg.ClientNetworkingCertRequest);
                clientCertRequest.Body.key_data = new byte[] {  };     //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX4
                clientCertRequest.Body.app_id   = CSGO_APPID;
                steamClient.Send(clientCertRequest);
                break;

            default:
                form.AddLog(String.Format("[ERROR] Can't connect to steam: {0} / {1}", callback.Result, callback.ExtendedResult));
                return;
            }

            await Task.Delay(5000).ConfigureAwait(false);
        }
Exemplo n.º 30
0
        public void OnSteambotLoggedIn(SteamUser.LoggedOnCallback callback)
        {
            switch (callback.Result)
            {
            case EResult.OK:
                myUserNonce = callback.WebAPIUserNonce;
                Console.WriteLine("Logged in to steam !");
                break;

            case EResult.AccountLoginDeniedNeedTwoFactor:
            case EResult.AccountLogonDenied:

                bool isSteamGuard = callback.Result == EResult.AccountLogonDenied;
                bool is2FA        = callback.Result == EResult.AccountLoginDeniedNeedTwoFactor;

                if (isSteamGuard || is2FA)
                {
                    Console.WriteLine("This account is SteamGuard protected!");

                    if (is2FA)
                    {
                        Console.WriteLine("Generating 2 factor auth code...");

                        string authCode = GetMobileAuthCode();
                        loginInfo.SetTwoFactorCode(authCode);
                    }
                    else
                    {
                        Console.WriteLine("Please enter the auth code sent to the email at {0}: ", callback.EmailDomain);
                        loginInfo.SetAuthCode(Console.ReadLine());
                    }
                }
                break;

            case EResult.TwoFactorCodeMismatch:
            case EResult.TwoFactorActivationCodeMismatch:
                stop = true;
                Console.WriteLine("The 2 factor auth code is wrong ! Asking it again : ");
                loginInfo.SetTwoFactorCode(Console.ReadLine());
                break;

            case EResult.InvalidLoginAuthCode:
                stop = true;
                Console.WriteLine("The auth code (email) is wrong ! Asking it again : ");
                loginInfo.SetAuthCode(Console.ReadLine());
                break;

            default:
                loginInfo.LoginFailCount++;
                Console.WriteLine("Loggin failed ({0} times) ! {1}", loginInfo.LoginFailCount, callback.Result);

                if (loginInfo.LoginFailCount == 3)
                {
                    stop = true;
                }
                break;
            }
        }