Ejemplo n.º 1
0
        public bool CensorCheck(string CheckString)
        {
            foreach (string word in CheckString.Split(' ').ToArray())
            {
                if (CensoredWords.ContainsKey(word.ToLower()))
                {
                    return(true);
                }
            }

            return(false);
        }
        public bool needsCensor(string text)
        {
            bool result = false;

            for (int i = 0; i < CensoredWords.ToArray().Length - 1; i++)
            {
                string regularExpression = ToRegexPattern(CensoredWords[i]);
                bool   flagable          = Regex.IsMatch(text, regularExpression, RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.CultureInvariant); // check for ass
                if (flagable)
                {
                    result = true;
                    break;
                }
                //checked for variations of the word ie: @$$ a$$ @ss a$s as$
                for (int j = 0; j < txtin_spelling.Count - 1; j++)
                {
                    string subed = Regex.Replace(CensoredWords[i], txtin_spelling[j].Key, txtin_spelling[j].Value, RegexOptions.IgnoreCase);
                    string regularExpression2 = ToRegexPattern(subed);
                    flagable = Regex.IsMatch(text, regularExpression2, RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.CultureInvariant);
                    if (flagable)
                    {
                        result = true;
                        break;
                    }
                }
                if (result)
                {
                    result = true;
                    break;
                }
            }

            /*
             * foreach (string censoredWord in CensoredWords)
             * {
             *  string regularExpression = ToRegexPattern(censoredWord);
             *  censoredText = Regex.Replace(text, regularExpression, StarCensoredMatch, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
             * }*/
            return(result);
        }
Ejemplo n.º 3
0
        public string QuickFilter(string message)
        {
            string[] words       = message.ToLower().Split((char[])null, StringSplitOptions.RemoveEmptyEntries);
            string   quickfilter = message;

            Dictionary <string, string> temp = new Dictionary <string, string>(words.Length);

            foreach (string word in words)
            {
                if (!temp.ContainsKey(word))
                {
                    temp.Add(word, word);
                    if (CensoredWords.ContainsKey(word))
                    {
                        string regularExpression = ToRegexPattern(word);

                        quickfilter = Regex.Replace(quickfilter, regularExpression, StarCensoredMatch,
                                                    RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
                    }
                }
            }
            return(quickfilter);
        }
Ejemplo n.º 4
0
 public void FilterAdd(string word)
 {
     CensoredWords.Add(word, word);
     SortCensoredWords();
     UpdateCensoredWords();
 }
Ejemplo n.º 5
0
 public bool FilterContains(string word)
 {
     return(CensoredWords.ContainsKey(word));
 }
Ejemplo n.º 6
0
 public void FilterRemove(string word)
 {
     CensoredWords.Remove(word);
     SortCensoredWords();
     UpdateCensoredWords();
 }