public void SendCommand(BotControlCommand cmd, bool echo = true) { if (Runner?.Hub.Config.SkipConsoleBotCreation != false) { return; } var bot = GetBot(); switch (cmd) { case BotControlCommand.Idle: bot.Pause(); break; case BotControlCommand.Start: bot.Start(); break; case BotControlCommand.Stop: bot.Stop(); break; case BotControlCommand.Resume: bot.Resume(); break; default: WinFormsUtil.Alert($"{cmd} is not a command that can be sent to the Bot."); return; } if (echo) { EchoUtil.Echo($"{bot.Bot.Connection.Name} has been issued a command to {cmd}."); } }
private void SendAll(BotControlCommand cmd) { foreach (var c in FLP_Bots.Controls.OfType <BotController>()) { c.SendCommand(cmd, false); } EchoUtil.Echo($"All bots have been issued a command to {cmd}."); }
public static bool IsUsable(this BotControlCommand cmd, bool running, bool paused) { return(cmd switch { BotControlCommand.Start => !running, BotControlCommand.Stop => running, BotControlCommand.Idle => running && !paused, BotControlCommand.Resume => paused, _ => false, });
public static bool IsUsableWhileRunning(this BotControlCommand cmd) { switch (cmd) { case BotControlCommand.Stop: case BotControlCommand.Idle: return(true); default: return(false); } }
public void SendCommand(BotControlCommand cmd, bool echo = true) { if (Runner?.Hub.Config.SkipConsoleBotCreation != false) { return; } var bot = GetBot(); switch (cmd) { case BotControlCommand.Idle: bot.Pause(); break; case BotControlCommand.Start: bot.Start(); break; case BotControlCommand.Stop: bot.Stop(); break; case BotControlCommand.Resume: bot.Resume(); break; case BotControlCommand.Restart: { var prompt = WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Are you sure you want to restart the connection?"); if (prompt != DialogResult.Yes) { return; } bot.Bot.Connection.Reset(bot.Bot.Config.IP); bot.Start(); break; } default: WinFormsUtil.Alert($"{cmd} is not a command that can be sent to the Bot."); return; } if (echo) { EchoUtil.Echo($"{bot.Bot.Connection.Name} has been issued a command to {cmd}."); } }