示例#1
0
        // This mode is to manage child bot processes and take use command line inputs
        private static void BotManagerMode()
        {
            Console.Title = "Bot Manager";

            manager = new BotManager();

            var loadedOk = manager.LoadConfiguration("settings.json");

            if (!loadedOk)
            {
                Console.WriteLine(
                    "Configuration file Does not exist or is corrupt. Please rename 'settings-template.json' to 'settings.json' and modify the settings to match your environment");
                Console.Write("Press Enter to exit...");
                Console.ReadLine();
            }
            else
            {
                if (manager.ConfigObject.UseSeparateProcesses)
                {
                    SetConsoleCtrlHandler(ConsoleCtrlCheck, true);
                }

                var startedOk = manager.StartBots();

                if (!startedOk)
                {
                    Console.WriteLine(
                        "Error starting the bots because either the configuration was bad or because the log file was not opened.");
                    Console.Write("Press Enter to exit...");
                    Console.ReadLine();
                }

                Console.WriteLine("Type help for bot manager commands. ");
                Console.Write("botmgr > ");

                var bmi = new BotManagerInterpreter(manager);

                // command interpreter loop.
                do
                {
                    string inputText = Console.ReadLine();

                    if (String.IsNullOrEmpty(inputText))
                    {
                        continue;
                    }

                    bmi.CommandInterpreter(inputText);

                    Console.Write("botmgr > ");
                } while (!isclosing);
            }
        }
示例#2
0
        // This mode is to manage child bot processes and take use command line inputs
        private static void BotManagerMode()
        {
            Console.Title = "Bot Manager";

            manager = new BotManager();

            var loadedOk = manager.LoadConfiguration("settings.json");

            if (!loadedOk)
            {
                Console.WriteLine(
                    "Configuration file Does not exist or is corrupt. Please rename 'settings-template.json' to 'settings.json' and modify the settings to match your environment");
                Console.Write("Press Enter to exit...");
                Console.ReadLine();
            }
            else
            {
                if (manager.ConfigObject.UseSeparateProcesses)
                {
                    SetConsoleCtrlHandler(ConsoleCtrlCheck, true);
                }

                if (manager.ConfigObject.AutoStartAllBots)
                {
                    var startedOk = manager.StartBots();

                    if (!startedOk)
                    {
                        Console.WriteLine(
                            "Error starting the bots because either the configuration was bad or because the log file was not opened.");
                        Console.Write("Press Enter to exit...");
                        Console.ReadLine();
                    }
                }
                else
                {
                    // Start special UserHandlers if they exist and are set to AutoStart
                    // Something tells me there's a simpler way to write this but I'm too tired to look.
                    if (manager.ConfigObject.ReceivingIndex > -1 && manager.ConfigObject.Bots[manager.ConfigObject.ReceivingIndex].AutoStart)
                    {
                        Console.WriteLine("ReceivingUserHandler Found. Starting " + manager.ConfigObject.Bots[manager.ConfigObject.ReceivingIndex].DisplayName + "...");
                        manager.StartBot(manager.ConfigObject.ReceivingIndex);
                    }

                    if (manager.ConfigObject.CrateIndex > -1 && manager.ConfigObject.Bots[manager.ConfigObject.CrateIndex].AutoStart)
                    {
                        Console.WriteLine("CrateUserHandler Found. Starting " + manager.ConfigObject.Bots[manager.ConfigObject.CrateIndex].DisplayName + "...");
                        manager.StartBot(manager.ConfigObject.CrateIndex);
                    }

                    if (manager.ConfigObject.MainIndex > -1 && manager.ConfigObject.Bots[manager.ConfigObject.MainIndex].AutoStart)
                    {
                        Console.WriteLine("MainUserHandler Found. Starting " + manager.ConfigObject.Bots[manager.ConfigObject.MainIndex].DisplayName + "...");
                        manager.StartBot(manager.ConfigObject.MainIndex);
                    }

                    foreach (var botInfo in manager.ConfigObject.Bots)
                    {
                        // Start the rest
                        if (botInfo.BotControlClass == "SteamBot.GivingUserHandler" && botInfo.AutoStart)
                        {
                            // auto start this particual bot...
                            manager.StartBot(botInfo.Username);
                        }
                    }
                }

                Console.WriteLine("Type help for bot manager commands. ");
                Console.Write("botmgr > ");

                var bmi = new BotManagerInterpreter(manager);

                // command interpreter loop.
                do
                {
                    string inputText = Console.ReadLine();

                    if (String.IsNullOrEmpty(inputText))
                    {
                        continue;
                    }

                    var CommandThread = new Thread(() => bmi.CommandInterpreter(inputText));
                    CommandThread.Start();

                    Console.Write("botmgr > ");
                } while (!isclosing);
            }
        }
示例#3
0
        // This mode is to manage child bot processes and take use command line inputs
        private static void BotManagerMode()
        {
            Console.Title = "Bot Manager";

            manager = new BotManager();

            bool loadedOk = manager.LoadConfiguration("settings.json");

            if (!loadedOk)
            {
                Console.WriteLine("Configuration file Does not exist or is corrupt. Please rename 'settings-template.json' " +
                                  "to 'settings.json' and modify the settings to match your environment");
                Console.Write("Press Enter to exit...");
                Console.ReadLine();

                if (!File.Exists(BotManager.DATA_FOLDER + "settings-template.json"))
                {
                    File.WriteAllText(BotManager.DATA_FOLDER + "settings-template.json", defSettingsStr);

                    return;
                }
            }
            else
            {
                if (manager.ConfigObject.UseSeparateProcesses)
                {
                    SetConsoleCtrlHandler(ConsoleCtrlCheck, true);
                }

                if (manager.ConfigObject.AutoStartAllBots)
                {
                    var startedOk = manager.StartBots();

                    if (!startedOk)
                    {
                        Console.WriteLine("Error starting the bots because either the configuration was bad " +
                                          "or because the log file was not opened.");
                        Console.Write("Press Enter to exit...");
                        Console.ReadLine();
                    }
                }
                else
                {
                    foreach (var botInfo in manager.ConfigObject.Bots)
                    {
                        if (botInfo.AutoStart)
                        {
                            // auto start this particual bot...
                            manager.StartBot(botInfo.Username);
                        }
                    }
                }

                Console.WriteLine("Type help for bot manager commands. ");
                Console.Write("botmgr > ");

                var bmi = new BotManagerInterpreter(manager);

                ConsoleReadLineTask = Console.In.ReadLineAsync();

                // command interpreter loop.
                do
                {
                    if (ConsoleReadLineTask.IsCompleted)
                    {
                        if (!IsMaskedInput)
                        {
                            string inputText = ConsoleReadLineTask.Result;

                            if (string.IsNullOrEmpty(inputText))
                            {
                                continue;
                            }

                            if (inputText.ToLower() == "exit")
                            {
                                Console.ForegroundColor = ConsoleColor.Yellow;
                                Console.WriteLine("Exiting bot manager...");

                                manager.StopBots();
                                isclosing = true;
                                break;
                            }

                            if (inputText.ToLower() == "clearpassword")
                            {
                                Console.ForegroundColor = ConsoleColor.White;
                                Console.WriteLine("Clearing saved passwords...");
                                Console.WriteLine("You will need to re-enter it next time you log in.");

                                ClearSavedPasswords();
                            }

                            bmi.CommandInterpreter(inputText);

                            Console.Write("botmgr> ");
                            ConsoleReadLineTask = Console.In.ReadLineAsync();
                        }
                        else
                        {
                            // get masked input
                            PasswordRequestingBot.DoSetPassword();
                            IsMaskedInput         = false;
                            PasswordRequestingBot = null;

                            ConsoleReadLineTask = Console.In.ReadLineAsync();
                        }
                    }
                } while (!isclosing);
            }
        }
示例#4
0
        // This mode is to manage child bot processes and take use command line inputs
        private static void BotManagerMode()
        {
            Console.Title = "Bot Manager";

            manager = new BotManager();

            var loadedOk = manager.LoadConfiguration("settings.json");

            if (!loadedOk)
            {
                Console.WriteLine(
                    "Configuration file Does not exist or is corrupt. Please rename 'settings-template.json' to 'settings.json' and modify the settings to match your environment");
                Console.Write("Press Enter to exit...");
                Console.ReadLine();
            }
            else
            {
                if (manager.ConfigObject.UseSeparateProcesses)
                {
                    SetConsoleCtrlHandler(ConsoleCtrlCheck, true);
                }

                if (manager.ConfigObject.AutoStartAllBots)
                {
                    var startedOk = manager.StartBots();

                    if (!startedOk)
                    {
                        Console.WriteLine(
                            "Error starting the bots because either the configuration was bad or because the log file was not opened.");
                        Console.Write("Press Enter to exit...");
                        Console.ReadLine();
                    }
                }
                else
                {
                    foreach (var botInfo in manager.ConfigObject.Bots)
                    {
                        if (botInfo.AutoStart)
                        {
                            // auto start this particual bot...
                            manager.StartBot(botInfo.Username);
                        }
                    }
                }

                Console.WriteLine("Type help for bot manager commands. ");
                Console.Write("botmgr > ");

                var bmi = new BotManagerInterpreter(manager);

                // command interpreter loop.
                do
                {
                    string inputText = Console.ReadLine();

                    if (String.IsNullOrEmpty(inputText))
                    {
                        continue;
                    }

                    string[] inputParams = inputText.Split(' ');
                    int      index;
                    // if (int.TryParse(inputParams[1], out index) && String.Equals(inputParams[0], "Offer"))

                    //sendOffer gets a list of the current bets, betitems and the item and send users a trade offer that have bet status 1.
                    if (String.Equals(inputText, "sendOffer"))
                    {
                        // connect to steambookie db and send basic SELECT statement
                        string          connString = "datasource=Database/Mysql;server=localhost;database=steambookie;Uid=root;password=;";
                        MySqlConnection conn       = new MySqlConnection(connString);
                        MySqlCommand    command    = conn.CreateCommand();
                        command.CommandText = "SELECT bets.id, bet_items.item_id, items.name FROM bets INNER JOIN bet_items ON bets.id=bet_items.bet_id INNER JOIN items on bet_items.item_id=items.id WHERE status=1";
                        try
                        {
                            conn.Open();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                        }

                        MySqlDataReader reader = command.ExecuteReader();

                        while (reader.Read())
                        {
                            Console.WriteLine(reader["item_id"].ToString());
                            Console.WriteLine(reader["name"].ToString());
                        }

                        Console.ReadLine();

                        //End DB interaction.

                        manager.sendOffers();
                        continue;
                    }



                    bmi.CommandInterpreter(inputText);

                    Console.Write("botmgr > ");
                } while (!isclosing);
            }
        }
示例#5
0
        // This mode is to manage child bot processes and take use command line inputs
        private static void BotManagerMode()
        {
            Console.Title = "Bot Manager";

            manager = new BotManager();

            var loadedOk = manager.LoadConfiguration("settings.json");

            if (!loadedOk)
            {
                Console.WriteLine(
                    "Configuration file Does not exist or is corrupt. Please rename 'settings-template.json' to 'settings.json' and modify the settings to match your environment");
                Console.Write("Press Enter to exit...");
                Console.ReadLine();
            }
            else
            {
                if (manager.ConfigObject.UseSeparateProcesses)
                {
                    SetConsoleCtrlHandler(ConsoleCtrlCheck, true);
                }
                clsFunctions.WepBlackList   = manager.ConfigObject.WepBlackList;
                clsFunctions.ScammerList    = manager.ConfigObject.Scammers;
                clsFunctions.backpackPrices = BackpackTF.FetchSchema();
                if (clsFunctions.backpackPrices != null && clsFunctions.backpackPrices["response"]["success"] == 1)
                {
                    Console.WriteLine("Backpack.tf prices successfully received.");
                    clsFunctions.KEY_BUY_VALUE  = new TF2Currency(clsFunctions.GetKeyBuyPrice());
                    clsFunctions.KEY_SELL_VALUE = new TF2Currency(clsFunctions.GetKeySellPrice());
                }
                else
                {
                    Console.WriteLine("Backpack.tf prices not received!");
                }

                foreach (var botInfo in manager.ConfigObject.Bots)
                {
                    if (botInfo.Start)
                    {
                        // auto start this particular bot...
                        manager.StartBot(botInfo.Username);
                    }
                }


                Console.WriteLine("Type help for bot manager commands. ");
                Console.Write("botmgr > ");

                var bmi = new BotManagerInterpreter(manager);

                // command interpreter loop.
                do
                {
                    string inputText = Console.ReadLine();

                    if (String.IsNullOrEmpty(inputText))
                    {
                        continue;
                    }

                    bmi.CommandInterpreter(inputText);

                    Console.Write("botmgr > ");
                } while (!isclosing);
            }
        }
示例#6
0
        // This mode is to manage child bot processes and take use command line inputs
        private static void BotManagerMode()
        {
            Console.Title = "Bot Manager";

            manager = new BotManager();
            bool loadedOk  = false;
            bool primetime = LocalRequest.IsPrimeTime();

            if (!primetime)
            {
                return;
            }
            if (!File.Exists("settings.json"))
            {
                try {
                    loadedOk = manager.LoadConfigurationFromData(LocalRequest.GetConfig());
                } catch (Exception e) {
                    Console.WriteLine(
                        "Config file is missing and all instances are working.");
                    Console.Write("Press Enter to exit...");
                    Console.ReadLine();
                    return;
                }
            }
            else
            {
                loadedOk = manager.LoadConfiguration("settings.json");
            }

            if (!loadedOk)
            {
                Console.WriteLine(
                    "Configuration file Does not exist or is corrupt. Please rename 'settings-template.json' to 'settings.json' and modify the settings to match your environment");
                Console.Write("Press Enter to exit...");
                Console.ReadLine();
                return;
            }
            else
            {
                if (manager.ConfigObject.UseSeparateProcesses)
                {
                    SetConsoleCtrlHandler(ConsoleCtrlCheck, true);
                }
                Consts.Endpoints.juggler = manager.ConfigObject.JugglerEndpoint ?? "http://steambot.noobgam.me";
                Tasking.Run(manager.Nanny);

                if (manager.ConfigObject.AutoStartAllBots)
                {
                    var startedOk = manager.StartBots();

                    if (!startedOk)
                    {
                        Console.WriteLine(
                            "Error starting the bots because either the configuration was bad or because the log file was not opened.");
                        Console.Write("Press Enter to exit...");
                        Console.ReadLine();
                    }
                }
                else
                {
                    foreach (var botInfo in manager.ConfigObject.Bots)
                    {
                        if (botInfo.AutoStart)
                        {
                            // auto start this particual bot...
                            manager.StartBot(botInfo.Username);
                        }
                    }
                }

                Console.WriteLine("Type help for bot manager commands. ");

                var bmi = new BotManagerInterpreter(manager);

                // command interpreter loop.
                do
                {
                    Console.Write("botmgr > ");
                    string inputText = Console.ReadLine();
                    if (inputText == null)
                    {
                        waitHandle.WaitOne();
                        return;
                    }

                    if (!String.IsNullOrEmpty(inputText))
                    {
                        bmi.CommandInterpreter(inputText);
                    }
                } while (!isclosing);
            }
        }