/// <summary> /// Throw a message if we are successfully logged on /// Authenticate in the web, if we are successfully authenticated request a APIKey, join our group, start to check for tradeoffers and also start to farm for cards /// /// If we do not have linked a authenticator to our phone, print a message to let the user know to enter the code sent to the email /// If we do have linked a authenticator to our phone, try to get the authcode from our mobileHelper /// If the returned answer is empty tell the user to link it via the bot or add the .maFile to the directory in a specific format /// If the returned answer is not empty tell the user that we have generated the 2FA authcode /// /// If the entered/ returned authCode is false, align our time with the time of the steamservers and try again the upper case /// /// Throw a message if there occured an error /// </summary> /// <param name="_callback"></param> private async void OnLoggedOn(SteamUser.LoggedOnCallback _callback) { m_steamUserLogonDetails.AuthCode = ""; m_webAPIUserNonce = _callback.WebAPIUserNonce; switch (_callback.Result) { case EResult.OK: m_logger.Info("Successfully logged on."); bool loggedon = m_steamWeb.AuthenticateUser(m_steamClient, m_webAPIUserNonce); if (!loggedon) { while (!loggedon) { m_logger.Warning("Could not login, retrying in 5 seconds..."); Thread.Sleep(TimeSpan.FromSeconds(5)); loggedon = await m_steamWeb.RefreshSessionIfNeeded().ConfigureAwait(false); } } else { m_logger.Info("Successfully authenticated the user in the web."); await m_steamWeb.RequestAPiKey().ConfigureAwait(false); await m_steamUserWebAPI.JoinGroupIfNotJoinedAlready(m_steamFriends, 103582791458407475).ConfigureAwait(false); m_cardFarmHelper.StartFarmCards(m_steamClient); } break; case EResult.AccountLogonDenied: m_logger.Warning($"Enter the auth code sent to the email at: {_callback.EmailDomain}"); m_steamUserLogonDetails.AuthCode = Console.ReadLine(); break; case EResult.InvalidLoginAuthCode: m_logger.Warning($"Enter the new auth code sent to the email at: {_callback.EmailDomain}"); m_steamUserLogonDetails.AuthCode = Console.ReadLine(); break; case EResult.AccountLoginDeniedNeedTwoFactor: string twoFactorCode = m_mobileHelper.GetMobileAuthCode(m_steamUserLogonDetails.Username); if (string.IsNullOrEmpty(twoFactorCode)) { m_logger.Warning("Be sure to link the account to the mobileauthenticator via the bot or add the .maFile to the 2FAFiles directory with the format: 'username.auth'"); m_logger.Warning("If you have your phone already linked enter your code: "); m_steamUserLogonDetails.TwoFactorCode = Console.ReadLine(); } else { m_steamUserLogonDetails.TwoFactorCode = twoFactorCode; m_logger.Info("2FA-Code was generated."); } break; case EResult.TwoFactorCodeMismatch: TimeAligner.AlignTime(); twoFactorCode = m_mobileHelper.GetMobileAuthCode(m_steamUserLogonDetails.Username); if (string.IsNullOrEmpty(twoFactorCode)) { m_logger.Warning("Be sure to link the account to the mobileauthenticator via the bot or add the .maFile to the 2FAFiles directory with the format: 'username.auth'"); m_logger.Warning("If you have your phone already linked enter your code: "); m_steamUserLogonDetails.TwoFactorCode = Console.ReadLine(); } else { m_steamUserLogonDetails.TwoFactorCode = twoFactorCode; m_logger.Info("2FA-Code was generated."); } break; case EResult.RateLimitExceeded: m_logger.Error("Account timeout, wait 5 mins and then try again to login."); Thread.Sleep(TimeSpan.FromMinutes(5)); break; default: m_logger.Error($"Unable to logon to Steam: {_callback.Result} / { _callback.ExtendedResult}"); break; } }