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); }