Exemple #1
0
 public TMBot(Bot bot, Configuration.BotInfo config)
 {
     this.bot    = bot;
     this.config = new BotConfig(config);
     botName     = config.Username;
     //LocalRequest.PutTradeToken(botName, config.TradeToken);
     Init();
 }
Exemple #2
0
        public Bot(Configuration.BotInfo config, string apiKey, UserHandlerCreator handlerCreator, bool debug = false, bool process = false)
        {
            userHandlers = new Dictionary <SteamID, UserHandler>();
            logOnDetails = new SteamUser.LogOnDetails
            {
                Username = config.Username,
                Password = config.Password
            };
            DisplayName       = config.DisplayName;
            ChatResponse      = config.ChatResponse;
            DisplayNamePrefix = config.DisplayNamePrefix;
            schemaLang        = config.SchemaLang != null && config.SchemaLang.Length == 2 ? config.SchemaLang.ToLower() : "en";
            Admins            = config.Admins;
            ApiKey            = !String.IsNullOrEmpty(config.ApiKey) ? config.ApiKey : apiKey;
            isProccess        = process;
            try
            {
                if (config.LogLevel != null)
                {
                    consoleLogLevel = (Log.LogLevel)Enum.Parse(typeof(Log.LogLevel), config.LogLevel, true);
                    Console.WriteLine(@"(Console) LogLevel configuration parameter used in bot {0} is depreciated and may be removed in future versions. Please use ConsoleLogLevel instead.", DisplayName);
                }
                else
                {
                    consoleLogLevel = (Log.LogLevel)Enum.Parse(typeof(Log.LogLevel), config.ConsoleLogLevel, true);
                }
            }
            catch (ArgumentException)
            {
                Console.WriteLine(@"(Console) ConsoleLogLevel invalid or unspecified for bot {0}. Defaulting to ""Info""", DisplayName);
                consoleLogLevel = Log.LogLevel.Info;
            }

            try
            {
                fileLogLevel = (Log.LogLevel)Enum.Parse(typeof(Log.LogLevel), config.FileLogLevel, true);
            }
            catch (ArgumentException)
            {
                Console.WriteLine(@"(Console) FileLogLevel invalid or unspecified for bot {0}. Defaulting to ""Info""", DisplayName);
                fileLogLevel = Log.LogLevel.Info;
            }

            logFile         = config.LogFile;
            Log             = new Log(logFile, DisplayName, consoleLogLevel, fileLogLevel);
            createHandler   = handlerCreator;
            BotControlClass = config.BotControlClass;
            SteamWeb        = new SteamWeb();

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

            Log.Debug("Initializing Steam Bot...");
            SteamClient = new SteamClient();
            SteamClient.AddHandler(new SteamNotifications());
            SteamUser            = SteamClient.GetHandler <SteamUser>();
            SteamFriends         = SteamClient.GetHandler <SteamFriends>();
            SteamGameCoordinator = SteamClient.GetHandler <SteamGameCoordinator>();
            SteamNotifications   = SteamClient.GetHandler <SteamNotifications>();

            botThread = new BackgroundWorker {
                WorkerSupportsCancellation = true
            };
            botThread.DoWork             += BackgroundWorkerOnDoWork;
            botThread.RunWorkerCompleted += BackgroundWorkerOnRunWorkerCompleted;
            botThread.RunWorkerAsync();
        }
Exemple #3
0
 public BotConfig(Configuration.BotInfo steamConfig)
 {
     Api         = steamConfig.MarketApiKey;
     Username    = steamConfig.Username;
     DisplayName = steamConfig.DisplayName;
 }
Exemple #4
0
 public BitSkinsBot(Bot bot, Configuration.BotInfo config)
 {
     this.bot    = bot;
     this.config = new BotConfig(config);
     protocol    = new Protocol();
 }
Exemple #5
0
 public BotConfig(Configuration.BotInfo config)
 {
 }