// 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; bmi.CommandInterpreter(inputText); Console.Write("botmgr > "); } while (!isclosing); } }
// 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); } }
// This mode is to manage child bot processes and take use command line inputs private void BotManagerMode() { 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"); } 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."); } } else { foreach (var botInfo in manager.ConfigObject.Bots) { if (botInfo.AutoStart) { // auto start this particual bot... manager.StartBot(botInfo.Username); } } } wpfBotIndex = manager.botProcs.Count; if (wpfBotIndex != 0) { UpdateWindow(wpfBotIndex); } Console.WriteLine("Type help for bot manager commands. "); Console.Write("botmgr > "); var bmi = new BotManagerInterpreter(manager); // command interpreter loop. do { try { string inputText = Console.ReadLine(); if (String.IsNullOrEmpty(inputText)) { continue; } bmi.CommandInterpreter(inputText); Console.Write("botmgr > "); } catch (Exception e) { isclosing = true; } } while (!isclosing); } }
// 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); } }