Пример #1
0
 /// <summary>
 /// Class constructor
 /// Gets the steam guard account from file
 /// </summary>
 /// <param name="settings">Settings class for bot</param>
 public Authentication(AppSettings.BotSettings settings)
 {
     if ((mAccount = GetAccount(settings.username)) == null)
     {
         Console.WriteLine("An authenticator needs to be added to this account manually.");
         return;
     }
 }
Пример #2
0
        /// <summary>
        /// Class consntructor
        /// </summary>
        /// <param name="settings">Settings for this account</param>
        public Bot(AppSettings.BotSettings settings)
        {
            mSettings = settings;
            mBotType  = (BotType)settings.jobId;
            mLog      = new Log(settings.displayName, $"Logs\\Bot\\{settings.displayName}.txt", 3);
            mLogOffer = new Log(settings.displayName, $"Logs\\Bot\\{settings.displayName} Offers.txt", 3);

            mSteam.sentryPath   = Functions.GetStartFolder() + $"Sentryfiles\\{settings.username}.sentry";
            mSteam.logOnDetails = new SteamUser.LogOnDetails()
            {
                Username = settings.username,
                Password = settings.password,
                ShouldRememberPassword = true
            };
            mSteam.Web = new SteamWeb();
            ServicePointManager.ServerCertificateValidationCallback += mSteam.Web.ValidateRemoteCertificate;

            mSteam.Client          = new SteamClient();
            mSteam.Trade           = mSteam.Client.GetHandler <SteamTrading>();
            mSteam.CallbackManager = new CallbackManager(mSteam.Client);
            mSteam.User            = mSteam.Client.GetHandler <SteamUser>();
            mSteam.Friends         = mSteam.Client.GetHandler <SteamFriends>();
            mSteam.Auth            = new Authentication(settings);

            mSteam.CallbackManager.Subscribe <SteamClient.ConnectedCallback>(OnConnected);
            mSteam.CallbackManager.Subscribe <SteamClient.DisconnectedCallback>(OnDisconnected);
            mSteam.CallbackManager.Subscribe <SteamUser.LoggedOnCallback>(OnLoggedOn);
            mSteam.CallbackManager.Subscribe <SteamUser.LoginKeyCallback>(OnLoginKey);
            mSteam.CallbackManager.Subscribe <SteamUser.WebAPIUserNonceCallback>(OnWebAPIUserNonce);
            mSteam.CallbackManager.Subscribe <SteamUser.UpdateMachineAuthCallback>(OnUpdateMachineAuth);

            mBotThread = new BackgroundWorker {
                WorkerSupportsCancellation = true
            };
            mBotThread.DoWork             += BackgroundWorkerOnDoWork;
            mBotThread.RunWorkerCompleted += BackgroundWorkerOnRunWorkerCompleted;
            mBotThread.RunWorkerAsync();

            mLog.Write(Log.LogLevel.Info, "Initialized");
        }