/// <summary> /// OnLoggedOn Callback /// Fires when User logs in successfully /// </summary> /// <param name="callback"></param> private void OnLoggedOn(SteamUser.LoggedOnCallback callback) { /*Fetch if SteamGuard is required*/ if (callback.Result == EResult.AccountLogonDenied) { /*SteamGuard required*/ Print("Enter the SteamGuard code from your email:"); mSteam.loginDetails.AuthCode = Console.ReadLine(); return; } /*If two-way authentication*/ if(callback.Result == EResult.AccountLogonDeniedNeedTwoFactorCode) { /*Account requires two-way authentication*/ Print("Enter your two-way authentication code:"); mSteam.loginDetails.TwoFactorCode = Console.ReadLine(); return; } /*Something terrible has happened*/ string userInfo = string.Format("{0},{1}", mInfo.Username, mInfo.Password); if (callback.Result != EResult.OK) { /*Incorrect password*/ if (callback.Result == EResult.InvalidPassword) { /*Delete old user info*/ Properties.Settings.Default.UserInfo.Remove(userInfo); Properties.Settings.Default.Save(); Print("{0} - Invalid password! Try again:", callback.Result); mSteam.loginDetails.Password = Password.ReadPassword(); } /*Incorrect two-factor*/ if (callback.Result == EResult.TwoFactorCodeMismatch) { Print("{0} - Invalid two factor code! Try again:", callback.Result); mSteam.loginDetails.TwoFactorCode = Console.ReadLine(); } /*Incorrect email code*/ if (callback.Result == EResult.AccountLogonDenied) { Print("{0} - Invalid email auth code! Try again:", callback.Result); mSteam.loginDetails.AuthCode = Console.ReadLine(); } /*Disconnect and retry*/ mSteam.client.Disconnect(); mBotState = BotState.LoggedOut; return; } /*Logged in successfully*/ Print("Successfully logged in!\n"); mSteam.nounce = callback.WebAPIUserNonce; mBotState = BotState.LoggedIn; /*Since login was successfull we can save the password here*/ /*Yep, it's done in plaintext is resources. Deal with it.*/ if (!Properties.Settings.Default.UserInfo.Contains(userInfo)) { DialogResult dialogResult = MessageBox.Show("Do you want to save the password?", "Save info", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { Properties.Settings.Default.UserInfo.Add(userInfo); Properties.Settings.Default.Save(); } } /*Gets a random extra time for the timer*/ var random = new Random(); int extraTime = random.Next(20, 60); /*Set the timer if it's not already enabled*/ if (!mGameTimer.Enabled && mSettings.RestartGamesEveryThreeHours) { mGameTimer.Interval = TimeSpan.FromMinutes(180 + extraTime).TotalMilliseconds; mGameTimer.Elapsed += new ElapsedEventHandler(PreformStopStart); mGameTimer.Start(); } /*Set games playing*/ SetGamesPlaying(true); }