/// <summary> /// Gets the user in list depending on accountListBox index /// </summary> /// <param name="sender">object</param> /// <param name="e">EventArgs</param> private void accountListBox_SelectedIndexChanged(object sender, EventArgs e) { /*Selected item can be null if the text is changed by txtUsername_TextChanged*/ if (accountListBox.SelectedItem == null) return; /*Show the settings panel since we have an account to edit now*/ if (!panelSettings.Visible) panelSettings.Visible = true; /*Save the current account before switching*/ SaveCurrentAccount(); /*Set the active account depending on index selected in the listbox*/ mActiveAccount = mSettings.Accounts[accountListBox.SelectedIndex]; /*Assign text settings*/ txtUsername.Text = mActiveAccount.Details.Username; txtPassword.Text = mActiveAccount.Details.Password; txtLoginKey.Text = mActiveAccount.Details.LoginKey; txtResponse.Text = mActiveAccount.ChatResponse; /*Clear previous entries in game listbox and add new ones*/ gameList.Items.Clear(); mActiveAccount.Games.ForEach(o => gameList.Items.Add(o)); /*Assign bool settings*/ cbOnlineStatus.Checked = mActiveAccount.ShowOnlineStatus; cbJoinGroup.Checked = mActiveAccount.JoinSteamGroup; cbCommunity.Checked = mActiveAccount.ConnectToSteamCommunity; cbRestartGames.Checked = mActiveAccount.RestartGamesEveryThreeHours; }
/// <summary> /// Main initializer for each account /// </summary> /// <param name="info">Account info</param> public Bot(Config.AccountSettings info) { /*If a password isn't set we'll ask for user input*/ if (string.IsNullOrWhiteSpace(info.Details.Password) && string.IsNullOrWhiteSpace(info.Details.LoginKey)) { Console.WriteLine("Enter password for account '{0}'", info.Details.Username); info.Details.Password = Password.ReadPassword('*'); } /*Assign bot info*/ mSteam.loginDetails = new SteamUser.LogOnDetails() { Username = info.Details.Username, Password = info.Details.Password, LoginKey = info.Details.LoginKey, ShouldRememberPassword = true, }; mAccountSettings = info; mSteam.games = info.Games; mSteam.sentryPath = Path.Combine(Application.StartupPath, string.Format("Sentryfiles\\{0}.sentry", info.Details.Username)); /*Set up steamweb*/ mSteam.web = new SteamWeb(); ServicePointManager.ServerCertificateValidationCallback += mSteam.web.ValidateRemoteCertificate; /*Create logs*/ mLog = new Log(info.Details.Username, Path.Combine(EndPoint.LOG_FOLDER_PATH, $"{info.Details.Username}.txt"), 1); mLogChat = new Log($"{info.Details.Username} Chat", Path.Combine(EndPoint.LOG_FOLDER_PATH, $"{info.Details.Username} steam chat.txt"), 1); /*Assign clients*/ mSteam.client = new SteamClient(); mSteam.callbackManager = new CallbackManager(mSteam.client); mSteam.user = mSteam.client.GetHandler<SteamUser>(); mSteam.friends = mSteam.client.GetHandler<SteamFriends>(); mSteam.extraHandler = new ExtraHandler(this); mSteam.client.AddHandler(mSteam.extraHandler); /*Subscribe to Callbacks*/ mSteam.callbackManager.Subscribe<SteamClient.ConnectedCallback>(OnConnected); mSteam.callbackManager.Subscribe<SteamClient.DisconnectedCallback>(OnDisconnected); mSteam.callbackManager.Subscribe<SteamUser.LoggedOnCallback>(OnLoggedOn); mSteam.callbackManager.Subscribe<SteamUser.UpdateMachineAuthCallback>(OnMachineAuth); mSteam.callbackManager.Subscribe<SteamUser.LoginKeyCallback>(OnLoginKey); mSteam.callbackManager.Subscribe<SteamUser.WebAPIUserNonceCallback>(OnWebAPIUserNonce); mSteam.callbackManager.Subscribe<SteamFriends.FriendMsgCallback>(OnFriendMsgCallback); mSteam.callbackManager.Subscribe<ExtraHandler.PlayingSessionStateCallback>(OnPlayingSessionState); /*Start Callback thread*/ mBotThread.DoWork += BackgroundWorkerOnDoWork; mBotThread.RunWorkerCompleted += BackgroundWorkerOnRunWorkerCompleted; mBotThread.RunWorkerAsync(); Connect(); }