public bool CheckFlag(MBotMessage m) { try { string cmp = m.Text; if (!FlagIsCaseSensitive) { cmp = cmp.ToLower(); } bool ParamiterExists = cmp.Contains(" "); string paramBase = ParamiterExists ? cmp.Split(' ')[0] : cmp; if (FlagIsRegex && Handler.Command.Paramiter == ParamiterType.None) { return(Regex.Match(cmp, Flag).Success); } else { switch (Handler.Command.Paramiter) { case ParamiterType.Must: if (!ParamiterExists) { return(false); } return(paramBase == Flag); case ParamiterType.Optional: return(cmp == Flag || paramBase == Flag); case ParamiterType.None: return(cmp == Flag); } } return(true); } catch (Exception ex) { if (OnException != null) { OnException(Handler.Parent, ex); } return(false); } }
public bool CheckFlag(MBotMessage m) { try { string cmp = m.Text; if (!FlagIsCaseSensitive) cmp = cmp.ToLower(); bool ParamiterExists = cmp.Contains(" "); string paramBase = ParamiterExists ? cmp.Split(' ')[0] : cmp; if (FlagIsRegex && Handler.Command.Paramiter == ParamiterType.None) { return Regex.Match(cmp, Flag).Success; } else { switch (Handler.Command.Paramiter) { case ParamiterType.Must: if (!ParamiterExists) return false; return paramBase == Flag; case ParamiterType.Optional: return cmp == Flag || paramBase == Flag; case ParamiterType.None: return cmp == Flag; } } return true; } catch(Exception ex) { if (OnException != null) OnException(Handler.Parent, ex); return false; } }