/// <summary> /// Given a message, find corresponding command and run it. /// </summary> /// <param name="msg">The message that ran the command.</param> /// <param name="input">The input from the user.</param> public bool ExecuteUserInput(Matbot.Client.Message msg, ParsedInput p) { if (p == null) { return(false); } if (msg.User.BotRank == Client.UserRank.Gali) { bool c = true; if (p.Name != null) { if (p.Name.Equals("register")) { c = false; } } if (c) { msg.Reply(p.RawInput); return(true); } } if (p.IsCommand) { if (!Commands.ContainsKey(p.Name.ToLower())) { return(false); } Command c = Commands[p.Name.ToLower()]; if (c != null) { c.ReformatInput(p); List <object> parameters; try { CmdVariation v = c.FindCommandVariationByParsedInput(p, out parameters); c.ExecuteVariation(v, msg, parameters.ToArray()); } catch (CorrectVariationNotFoundException ex) { msg.Reply(ex.Message); return(false); } } else { return(false); } } else { return(false); } return(true); }
/// <summary> /// Given a message, find corresponding command and run it. /// </summary> /// <param name="msg">The message that ran the command.</param> /// <param name="input">The input from the user.</param> public bool ExecuteUserInput(Matbot.Client.Message msg, string input) { ParsedInput p = new ParsedInput(input); return(ExecuteUserInput(msg, p)); }