Jump to content

Block Spammers Change


Kardall

Recommended Posts

In regards to the Spammer Block list, I don't know why nobody does this but...

 

Instead of having the list a match of names, which it obviously does now, Have it let us put up to 200 entries of RegEx strings to block instead.

 

Things like this:

(^[_]{1,})   <--- More than one underscore in a row
(C_0)+   <--- Containing the phrase "C_0"
(W.W`)+   <--- Containing the phrase "W.W`"

 

Convert the list to a Tuple, pass it to a class that has a regex.Match() call that will return true or false if it finds a match. As long as it's false, continue on like normal. I know people will screw it up, but make it like an advanced option to turn it on, and you have to acknowledge that there is no support on your end from it. Let the users manage it, and do technical support for it.

 

Sticky a post somewhere that has a common list. or at the very least, "Here's how you match something you see in a spam message" kind of post. It's not difficult. Half the code is written already. You just have to change it from "does the name match what's in my list?" to "does the string match anything in my regex list?".

 

I will help you write the code if you really want. Just ask and I'll write a C# class for you...

 

Edit: Here You Go. Just .ToList() your Spam Block list to a Tuple<string, bool> where the boolean is true for a regex or false for just a string. That way you can have either handled.

 

Quote

public class RegExpSpamFilter
{
    private bool strPassed;
    public bool Match( string chatMessage, Tuple<string, bool> matchSet )
    {
        strPassed = true;        
        foreach( Tuple<int,string> pattern in matchSet )
        {
            if( pattern[1] == true ) // is a regex pattern
            {
                Match match = regex.Match(chatMessage,pattern[0], RegexOptions.IgnoreCase);
                if (match.Success)
                {
                    strPassed = false;
                }
            }
            else // is a string pattern
            {
                if( chatMessage.IndexOf(pattern[0], StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    strPassed = false; // Found
                }
            }
        }
        return strPassed;
    }
}

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...