Beispiel #1
0
        public override void OnLoggedOn(SteamUser.LoggedOnCallback callback)
        {
            switch (callback.Result)
            {
            case EResult.OK:
                _log.Debug("Successfully logged in. Requesting license for {id}...", GetAppID());

                _steamFriends.SetPersonaState(EPersonaState.Online);

                /*if (!Titan.Instance.Options.NoSteamGroup)
                 * {
                 *  LoginWebInterface(callback.ClientSteamID);
                 *  JoinSteamGroup(); // https://steamcommunity.com/groups/TitanReportBot
                 *  return;
                 * }*/

                var requestLicense = new ClientMsgProtobuf <CMsgClientRequestFreeLicense>(EMsg.ClientRequestFreeLicense);
                requestLicense.Body.appids.Add(GetAppID());
                _steamClient.Send(requestLicense);
                break;

            case EResult.AccountLoginDeniedNeedTwoFactor:
                if (!string.IsNullOrWhiteSpace(JsonAccount.SharedSecret))
                {
                    _log.Debug("A shared secret has been provided: automatically generating it...");

                    _2FactorCode = _sharedSecretGenerator.GenerateCode();
                }
                else
                {
                    _log.Information("Opening UI form to get the 2FA Steam Guard App Code...");

                    Application.Instance.Invoke(() => Titan.Instance.UIManager.ShowForm(
                                                    UIType.TwoFactorAuthentification, new _2FAForm(this)
                                                    ));

                    while (string.IsNullOrEmpty(_2FactorCode))
                    {
                        /* Wait until we receive the Steam Guard code from the UI */
                    }
                }

                if (!Titan.Instance.Options.Secure)
                {
                    _log.Information("Received 2FA Code: {Code}", _2FactorCode);
                }
                break;

            case EResult.AccountLogonDenied:
                _log.Information("Opening UI form to get the Auth Token from EMail...");

                Application.Instance.Invoke(() => Titan.Instance.UIManager.ShowForm(
                                                UIType.TwoFactorAuthentification, new _2FAForm(this, callback.EmailDomain)
                                                ));

                while (string.IsNullOrEmpty(_authCode))
                {
                    /* Wait until we receive the Auth Token from the UI */
                }

                if (!Titan.Instance.Options.Secure)
                {
                    _log.Information("Received Auth Token: {Code}", _authCode);
                }
                break;

            case EResult.ServiceUnavailable:
                _log.Error("Steam is currently offline. Please try again later.");

                Stop();
                break;

            case EResult.RateLimitExceeded:
                _log.Error("Steam Rate Limit has been reached. Please try it again in a few minutes...");

                Result = Result.RateLimit;
                Stop();
                break;

            case EResult.TwoFactorCodeMismatch:
            case EResult.TwoFactorActivationCodeMismatch:
            case EResult.Invalid:
                _log.Error("Invalid Steam Guard code provided. Reasking after reconnecting.");

                _authCode    = null;
                _2FactorCode = null;
                break;

            default:
                _log.Error("Unable to logon to account: {Result}: {ExtendedResult}", callback.Result, callback.ExtendedResult);

                Stop();
                break;
            }
        }
Beispiel #2
0
        public override void OnLoggedOn(SteamUser.LoggedOnCallback callback)
        {
            switch (callback.Result)
            {
            case EResult.OK:
                _log.Debug("Successfully logged in. Registering that we're playing CS:GO...");

                _steamFriends.SetPersonaState(EPersonaState.Online);

                var playGames = new ClientMsgProtobuf <CMsgClientGamesPlayed>(EMsg.ClientGamesPlayed);
                playGames.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed
                {
                    game_id = GetAppID()
                });
                _steamClient.Send(playGames);

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

                _log.Debug("Successfully registered playing CS:GO. Sending client hello to CS:GO services.");

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

                _gameCoordinator.Send(clientHello, GetAppID());
                break;

            case EResult.AccountLoginDeniedNeedTwoFactor:
                if (!string.IsNullOrWhiteSpace(JsonAccount.SharedSecret))
                {
                    _log.Debug("A shared secret has been provided: automatically generating it...");

                    _2FactorCode = _sharedSecretGenerator.GenerateCode();
                }
                else
                {
                    _log.Information("Opening UI form to get the 2FA Steam Guard App Code...");

                    Application.Instance.Invoke(() => Titan.Instance.UIManager.ShowForm(
                                                    UIType.TwoFactorAuthentification, new _2FAForm(this)
                                                    ));

                    while (string.IsNullOrEmpty(_2FactorCode))
                    {
                        /* Wait until we receive the Steam Guard code from the UI */
                    }
                }

                if (!Titan.Instance.Options.Secure)
                {
                    _log.Information("Received 2FA Code: {Code}", _2FactorCode);
                }
                break;

            case EResult.AccountLogonDenied:
                _log.Information("Opening UI form to get the Auth Token from EMail...");

                Application.Instance.Invoke(() => Titan.Instance.UIManager.ShowForm(
                                                UIType.TwoFactorAuthentification, new _2FAForm(this, callback.EmailDomain)
                                                ));

                while (string.IsNullOrEmpty(_authCode))
                {
                    /* Wait until we receive the Auth Token from the UI */
                }

                if (!Titan.Instance.Options.Secure)
                {
                    _log.Information("Received Auth Token: {Code}", _authCode);
                }
                break;

            case EResult.ServiceUnavailable:
                _log.Error("Steam is currently offline. Please try again later.");

                Stop();
                break;

            case EResult.RateLimitExceeded:
                _log.Error("Steam Rate Limit has been reached. Please try it again in a few minutes...");

                Result = Result.RateLimit;
                Stop();
                break;

            case EResult.TwoFactorCodeMismatch:
            case EResult.TwoFactorActivationCodeMismatch:
            case EResult.Invalid:
                _log.Error("Invalid Steam Guard code provided. Reasking after reconnecting.");

                _authCode    = null;
                _2FactorCode = null;
                break;

            default:
                _log.Error("Unable to logon to account: {Result}: {ExtendedResult}", callback.Result, callback.ExtendedResult);

                Stop();
                break;
            }
        }
Beispiel #3
0
        public override void OnLoggedOn(SteamUser.LoggedOnCallback callback)
        {
            switch (callback.Result)
            {
            case EResult.OK:
                _log.Debug("Successfully logged in. Registering that we're playing app {id}...", GetAppID());

                _steamFriends.SetPersonaState(EPersonaState.Online);

                /*if (!Titan.Instance.Options.NoSteamGroup)
                 * {
                 *  LoginWebInterface(callback.ClientSteamID);
                 *  JoinSteamGroup(); // https://steamcommunity.com/groups/TitanReportBot
                 *  return;
                 * }*/

                var playGames = new ClientMsgProtobuf <CMsgClientGamesPlayed>(EMsg.ClientGamesPlayed);
                playGames.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed
                {
                    game_id = GetAppID()
                });
                _steamClient.Send(playGames);

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

                _log.Debug("Successfully registered app {game}. Sending client hello to gc services.", GetAppID());

                switch (GetAppID())
                {
                case CSGO_APPID:
                {
                    var clientHello = new ClientGCMsgProtobuf <SteamKit2.GC.CSGO.Internal.CMsgClientHello>(
                        (uint)SteamKit2.GC.CSGO.Internal.EGCBaseClientMsg.k_EMsgGCClientHello
                        );

                    _gameCoordinator.Send(clientHello, GetAppID());
                    break;
                }

                case TF2_APPID:
                {
                    var clientInit = new ClientGCMsgProtobuf <CMsgTFClientInit>(
                        (uint)ETFGCMsg.k_EMsgGC_TFClientInit
                        )
                    {
                        Body =
                        {
                            //client_version = 4478108, // up2date as of 17th may 2018
                            //client_versionSpecified = true,

                            language          = 0, // We are english
                            languageSpecified = true
                        }
                    };

                    _gameCoordinator.Send(clientInit, GetAppID());


                    _log.Debug("SUCCESSFULLY SENT TF2 CLIENT INIT");

                    var clientHello = new ClientGCMsgProtobuf <SteamKit2.GC.TF2.Internal.CMsgClientHello>(
                        (uint)SteamKit2.GC.TF2.Internal.EGCBaseClientMsg.k_EMsgGCClientHello
                        );

                    _gameCoordinator.Send(clientHello, GetAppID());

                    _log.Debug("SUCCESSFULLY SENT TF2 CLIENT HELLO");
                    break;
                }
                }
                break;

            case EResult.AccountLoginDeniedNeedTwoFactor:
                if (!string.IsNullOrWhiteSpace(JsonAccount.SharedSecret))
                {
                    _log.Debug("A shared secret has been provided: automatically generating it...");

                    _2FactorCode = _sharedSecretGenerator.GenerateCode();
                }
                else
                {
                    _log.Information("Opening UI form to get the 2FA Steam Guard App Code...");

                    Application.Instance.Invoke(() => Titan.Instance.UIManager.ShowForm(
                                                    UIType.TwoFactorAuthentification, new _2FAForm(this)
                                                    ));

                    while (string.IsNullOrEmpty(_2FactorCode))
                    {
                        /* Wait until we receive the Steam Guard code from the UI */
                    }
                }

                if (!Titan.Instance.Options.Secure)
                {
                    _log.Information("Received 2FA Code: {Code}", _2FactorCode);
                }
                break;

            case EResult.AccountLogonDenied:
                _log.Information("Opening UI form to get the Auth Token from EMail...");

                Application.Instance.Invoke(() => Titan.Instance.UIManager.ShowForm(
                                                UIType.TwoFactorAuthentification, new _2FAForm(this, callback.EmailDomain)
                                                ));

                while (string.IsNullOrEmpty(_authCode))
                {
                    /* Wait until we receive the Auth Token from the UI */
                }

                if (!Titan.Instance.Options.Secure)
                {
                    _log.Information("Received Auth Token: {Code}", _authCode);
                }
                break;

            case EResult.ServiceUnavailable:
                _log.Error("Steam is currently offline. Please try again later.");

                Stop();
                break;

            case EResult.RateLimitExceeded:
                _log.Error("Steam Rate Limit has been reached. Please try it again in a few minutes...");

                Result = Result.RateLimit;
                Stop();
                break;

            case EResult.TwoFactorCodeMismatch:
            case EResult.TwoFactorActivationCodeMismatch:
            case EResult.Invalid:
                _log.Error("Invalid Steam Guard code provided. Reasking after reconnecting.");

                _authCode    = null;
                _2FactorCode = null;
                break;

            default:
                _log.Error("Unable to logon to account: {Result}: {ExtendedResult}", callback.Result, callback.ExtendedResult);

                Stop();
                break;
            }
        }