public static bool IsScale(this BotCommand command, Direction?direction = null, RailwayType?type = null) { var cmd = command.ToString(); var result = cmd.StartsWith("Scale"); if (direction is Direction d) { result = result && cmd.EndsWith(d.ToString()); } if (type is RailwayType t) { result = result && cmd.Contains(t.ToString()); } return(result); }
public static string ExtractRailwayType(this BotCommand command) { if (!command.IsScale()) { return(null); } var cmd = command.ToString(); foreach (var type in new [] { "L1", "L2", "L3", "L4" }) { if (cmd.Contains(type)) { return(type); } } return(null); }
public static Direction?ExtractDirection(this BotCommand command) { if (!command.IsScale()) { return(null); } var cmd = command.ToString(); if (cmd.Length <= 7) { return(null); } var dir = cmd.Substring(7); if (Enum.TryParse(dir, out Direction direction)) { return(direction); } return(null); }
public static bool IsGoto(this BotCommand command) { var cmd = command.ToString(); return(cmd.StartsWith("Goto")); }
public static bool IsMutate(this BotCommand command) { var cmd = command.ToString(); return(cmd.StartsWith("Mutate")); }
public override string ToString() { return($"/{BotCommand.ToString().ToLower()} [{MainParamName}] - {Description}"); }
public void SetCommand(BotCommand cmd) { this.cmd = cmd.ToString(); }