Esempio n. 1
0
        /// <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.customText = info.CustomText;
            mSteam.sentryPath = 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();
        }
Esempio n. 2
0
        public static void UpdateAccount(Config.AccountSettings acc)
        {
            var settings = GetSettings();

            settings.Accounts.First(o => o.Details.Username == acc.Details.Username).Details.LoginKey = acc.Details.LoginKey;
            File.WriteAllText(EndPoint.SETTINGS_FILE_PATH, JsonConvert.SerializeObject(settings, Formatting.Indented));

            //var account = GetSettings().Accounts.First(o => o.Details.Username == acc.Details.Username);
            //account = acc;
            //File.WriteAllText(EndPoint.SETTINGS_FILE_PATH, JsonConvert.SerializeObject(settings, Formatting.Indented));
        }