/// <summary> /// Add a bot to the runner. /// </summary> /// <param name="type"></param> /// <param name="username"></param> /// <param name="password"></param> public void AddBot(Type type, string username, string password) { List <VTankBot> bots = BotRunner.GetRunningBots(); // Remove old bot if it exists. for (int i = 0; i < bots.Count; ++i) { VTankBot bot = bots[i]; if (bot.AuthInfo.Username == username) { Print("Removed duplicate bot {0}.", username); BotRunner.Kill(bot); break; } } AuthInfo auth = new AuthInfo(username, password); BotRunner.Register(type, auth, null); BotRunner.Start(false); Print("Added new bot, {0}.", username); if (OnBotChange != null) { OnBotChange(null); } }
public void ItStartsAndStopsABot() { BotRunner runner = new BotRunner(); BotStub bot = new BotStub(); runner.Start(bot); Thread.Sleep(millisecondsTimeout: 100); runner.Stop(); Assert.Greater(bot.get_updates_numcalls, 0); Assert.Greater(bot.handle_update_numcalls, 0); }
/// <summary> /// Start the bot manager. /// </summary> public void Start() { BotRunner.Start(false); }
public static void Main(string[] args) { bool loadGUI = true; string configFile = DefaultConfigFile; if (args.Length > 1) { // Command-line arguments exist. for (int i = 0; i < args.Length; ++i) { if (args[i] == "-c" || args[i] == "--config-file") { // Argument: custom configuration file. if (args.Length >= i + 1) { PrintUsage("-c", "filename"); } configFile = args[i + 1]; ++i; } else if (args[i] == "-ng" || args[i] == "--nogui" || args[i] == "nogui") { // Argument: Hide the GUI. loadGUI = false; } } } try { WeaponLoader.LoadFiles(); BotRunner runner = new BotRunner(); if (loadGUI) { try { Application.Run(new MainWindow(configFile, runner)); } catch (Exception e) { MessageBox.Show("Error: " + e.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(1); } } else { runner.Parse(configFile); runner.Start(true); } } catch (Exception e) { Console.Error.WriteLine("Error!"); Console.Error.WriteLine(e); Console.Error.WriteLine(e.StackTrace); throw; } }