示例#1
0
 /// <summary>
 /// Checks if any of loaded ignores is matching this text
 /// </summary>
 /// <param name="text"></param>
 /// <param name="user"></param>
 /// <returns></returns>
 public static bool Matches(string text, User user = null)
 {
     // we need to walk through list of all ignores to find out
     foreach (Ignore x in IgnoreList)
     {
         // first of all we need to know if it's enabled, otherwise there is no point in checking it
         if (x.Enabled)
         {
             // if it's simple match we only check the text
             if (x.Simple)
             {
                 // if user is null we can skip it
                 if (user != null && x.type == Ignore.Type.User)
                 {
                     if (user.ToString().Contains(x.Text))
                     {
                         return true;
                     }
                 }
                 if (x.type == Ignore.Type.Everything)
                 {
                     if (text.Contains(x.Text))
                     {
                         return true;
                     }
                 }
             }
             else
             {
                 if (user != null && x.type == Ignore.Type.User)
                 {
                     if (x.regex.IsMatch(user.ToString()))
                     {
                         return true;
                     }
                 }
                 if (x.type == Ignore.Type.Everything)
                 {
                     if (x.regex.IsMatch(text))
                     {
                         return true;
                     }
                 }
             }
         }
     }
     return false;
 }