Exemple #1
0
		public Bot(Configuration.BotInfo config, string apiKey, bool debug = false) {
			sql = new Sql();

			Username = config.Username;
			Password = config.Password;
			DisplayName = config.DisplayName;
			Admins = config.Admins;
			id = config.Id;
			this.apiKey = apiKey;

			TradeListener = new ScrapTrade(this);
			TradeListenerInternal = new ExchangeTrade(this);
			TradeListenerAdmin = new AdminTrade(this);

			List<object[]> result = sql.query("SELECT text, response FROM responses");
			foreach (object[] row in result) {
				responses.Add(((string) row[0]).ToLower(), (string) row[1]);
			}

			// Hacking around https
			ServicePointManager.ServerCertificateValidationCallback += SteamWeb.ValidateRemoteCertificate;

			SteamClient = new SteamClient();
			SteamTrade = SteamClient.GetHandler<SteamTrading>();
			SteamUser = SteamClient.GetHandler<SteamUser>();
			SteamFriends = SteamClient.GetHandler<SteamFriends>();
			queueHandler = new QueueHandler(this);

			SteamClient.Connect();

			while (true) {
				Update();
			}
		}
Exemple #2
0
        public Bot(Configuration.BotInfo config, string apiKey, bool debug = false)
        {
            Username     = config.Username;
            Password     = config.Password;
            DisplayName  = config.DisplayName;
            ChatResponse = config.ChatResponse;
            Admins       = config.Admins;
            this.apiKey  = apiKey;
            AuthCode     = null;

            TradeListener = new TradeEnterTradeListener(this);

            // Hacking around https
            ServicePointManager.ServerCertificateValidationCallback += SteamWeb.ValidateRemoteCertificate;

            SteamClient = new SteamClient();
            SteamTrade = SteamClient.GetHandler<SteamTrading>();
            SteamUser = SteamClient.GetHandler<SteamUser>();
            SteamFriends = SteamClient.GetHandler<SteamFriends>();

            SteamClient.Connect();

            Thread CallbackThread = new Thread(() => // Callback Handling
                       {
                while (true)
                {
                    CallbackMsg msg = SteamClient.WaitForCallback (true);
                    HandleSteamMessage (msg);
                }
            });

            new Thread(() => // Trade Polling if needed
                       {
                while (true)
                {
                    Thread.Sleep (800);
                    if (CurrentTrade != null)
                    {
                        try
                        {
                            CurrentTrade.Poll ();
                        }
                        catch (Exception e)
                        {
                            Console.Write ("Error polling the trade: ");
                            Console.WriteLine (e);
                        }
                    }
                }
            }).Start ();

            CallbackThread.Start();
            CallbackThread.Join();
        }
Exemple #3
0
        public Bot(Configuration.BotInfo config, string apiKey, bool debug = false)
        {
            Username     = config.Username;
            Password     = config.Password;
            DisplayName  = config.DisplayName;
            ChatResponse = config.ChatResponse;
            MaximumTradeTime = config.MaximumTradeTime;
            MaximiumActionGap = config.MaximumActionGap;
            DisplayNamePrefix = config.DisplayNamePrefix;
            TradePollingInterval = config.TradePollingInterval <= 100 ? 800 : config.TradePollingInterval;
            Admins       = config.Admins;
            this.apiKey  = apiKey;
            AuthCode     = null;
            log          = new Log (config.LogFile, this);

            TradeListener = new TradeEnterTradeListener(this);

            // Hacking around https
            ServicePointManager.ServerCertificateValidationCallback += SteamWeb.ValidateRemoteCertificate;

            log.Debug ("Initializing Steam Bot...");
            SteamClient = new SteamClient();
            SteamTrade = SteamClient.GetHandler<SteamTrading>();
            SteamUser = SteamClient.GetHandler<SteamUser>();
            SteamFriends = SteamClient.GetHandler<SteamFriends>();
            log.Info ("Connecting...");
            SteamClient.Connect();

            Thread CallbackThread = new Thread(() => // Callback Handling
                       {
                while (true)
                {
                    CallbackMsg msg = SteamClient.WaitForCallback (true);
                    HandleSteamMessage (msg);
                }
            });

            new Thread(() => // Trade Polling if needed
                       {
                while (true)
                {
                    Thread.Sleep (TradePollingInterval);
                    if (CurrentTrade != null)
                    {
                        try
                        {
                            CurrentTrade.Poll ();
                        }
                        catch (Exception e)
                        {
                            log.Error ("Error Polling Trade: " + e);
                            //Console.Write ("Error polling the trade: ");
                            //Console.WriteLine (e);
                        }
                    }
                }
            }).Start ();

            CallbackThread.Start();
            log.Success ("Done Loading Bot!");
            CallbackThread.Join();
        }