Raised This Month: $7 Target: $400
 1% 

REGEX Word Filter


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Plugin ID:
393
Plugin Version:
1.2
Plugin Category:
Admin Commands
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
    68 
    Plugin Description:
    Provides advanced word filter management
    Old 05-26-2008 , 02:24   REGEX Word Filter
    Reply With Quote #1

    Want to filter not only dirty words and potentially offensive phrases, but also things like IP and email addresses? Then this plugin is for you!

    This plugin provides the ability to do the following things if a clients say text matches a provided REGEX pattern.

    (chatpattern) for chat

    1. Execute an RCON command (action)
    2. Limit the amount of times such a pattern may be spoken (limit)
    3. Enforce the limit with a block of the text
    4. Enforce the limit with a punishment RCON command (punish)
    5. Allow for forgiveness of one violation every x seconds (forgive)
    5. Block the text absolutely (no limit) (block)
    6. Replace the matches with a string (replace)
    7. Replace matches from ANOTHER REGEX pattern with a string (replacepattern)
    8. Warn the client they are violating the matching rules (warn)
    9. Allow admins with specified levels to be immune (immunity)

    All of this is done via a simple file format, no commands required!

    Format:

    The file, configs/regexrestrict.cfg, is structured in typical SM structure.
    To group a bunch of patterns to specific rules, put them all into a subsection together.

    Ex.

    Code:
    "Censor"
    {
    	"ExampleBlock"
    	{
    		"chatpattern"		"fuck 'CASELESS'"
    		"warn"				"Don't say that!"
    		"replace"			"FACK"
    	}
    }
    Here are the usable blocks:

    Chat Pattern: Search for a pattern

    Code:
    "chatpattern" "pattern 'flags'"
    Multiple flags can be used, seperate them with a |.
    If no flags are set, omit the delimiting single quote characters.
    You may also delimit the pattern with single quotes for prettiness, ala:

    Code:
    "chatpattern" " 'pattern' 'flags' "
    Valid Flags:
    Code:
    CASELESS - Ignore Case.
    MULTILINE - Multilines (affects ^ and $ so that they match the start/end of a line rather than matching the start/end of the string).
    DOTALL - Single line (affects . so that it matches any character, even new line characters). 
    EXTENDED - Pattern extension (ignore whitespace and # comments).
    UNGREEDY - Invert greediness of quantifiers
    UTF8 - Use UTF-8 Chars */
    NO_UTF8_CHECK - Do not check the pattern for UTF-8 validity (only relevant if PCRE_UTF8 is set)
    Warn: Display a warning message to the player

    Code:
    "warn" "msg"
    Allows you to give fair warning about your rules when they are broken

    Action: Executed if a pattern matches

    Code:
    "action" "rcon action"
    "rcon action" can be any command you want, but there may be only one action per section.

    %n, %i, and %u will be replaced with the clients name, index, or userid, respectively, if they are in the command string.

    Block: Block the text absolutely

    Code:
    "block" "1"
    Very simple, skips all the replacement stuff, does not skip the limiting step, so you can block and limit at the same time (limit the amount of times one can attempt to say it, and also block the words from being said)

    Limit: Limit the amount of times a piece of text can be said

    Code:
    "limit" "number"
    Also simple, will block if the client says the pattern more times than "number"

    Forgive: Forgives one indiscretion every x seconds

    Code:
    "forgive" "x"
    Allows more flexibility with limiting. It might be ok to advertise once every five minutes, not every five seconds, so you can "forgive" a slip up every "x" seconds.

    Punish: executes a punishment command if limit is exceeded

    Code:
    "punish" "cmd"
    "cmd" can be any command you want, but there may be only one punishment per section.

    %n, %i, and %u will be replaced with the clients name, index, or userid, respectively, if they are in the command string.

    Replace: I think you get it

    Code:
    "replace" "with"
    Will replace the pattern's matches with "with", and check everything again. This can cause an avalanche effect if "with" matches a previous pattern somehow, rendering many changes, which wastes CPU, but can render interesting messages.


    Replace Pattern: Replace against a pattern

    To be added soon, currently just deletes based on pattern


    To do:
    Allow name and command enforcement

    Have fun!

    Edit: Altered slightly; will now accept a map based regex file, of the format "regexfilter_MAPNAME.cfg", and will power off if no regex filter files are found (for efficiency reasons).
    Attached Thumbnails
    Click image for larger version

Name:	testing.PNG
Views:	5379
Size:	15.8 KB
ID:	26955  
    Attached Files
    File Type: sp Get Plugin or Get Source (sm_regexfilter.sp - 7409 views - 11.5 KB)
    File Type: cfg regexrestrict.cfg (440 Bytes, 4404 views)
    __________________

    Last edited by Twilight Suzuka; 06-14-2009 at 08:16.
    Twilight Suzuka is offline
    Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
    DJ Tsunami
    DJ Post Spammer
    Join Date: Feb 2008
    Location: The Netherlands
    Old 05-26-2008 , 08:10   Re: REGEX Word Filter
    Reply With Quote #2

    Sweet!
    __________________
    Advertisements | REST in Pawn - HTTP client for JSON REST APIs
    Please do not PM me with questions. Post in the plugin thread.
    DJ Tsunami is offline
    JiK
    New Member
    Join Date: May 2008
    Old 05-26-2008 , 11:18   Re: REGEX Word Filter
    Reply With Quote #3

    I get "Plugin failed to compile!" when trying to download.
    When I tried to compile from source I got
    sm_regexfilter.sp(3) : fatal error 120: cannot read from file: "regex"

    Any ideas? Am I missing something?
    JiK is offline
    Twilight Suzuka
    bad
    Join Date: Jul 2004
    Location: CS lab
    Old 05-26-2008 , 12:12   Re: REGEX Word Filter
    Reply With Quote #4

    Every god damn plugin...

    You need to compile it on your LOCAL MACHINE against the LATEST BUILD. REGEX is a new extention, and you probably don't have it yet, so you need to upgrade, possibly to the unstable branch. My current version is 1.1.0.2061
    __________________
    Twilight Suzuka is offline
    Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
    Twilight Suzuka
    bad
    Join Date: Jul 2004
    Location: CS lab
    Old 05-26-2008 , 17:47   Re: REGEX Word Filter
    Reply With Quote #5

    Note: There is a small bug, forgive isn't working quite the way it should. I'll fix it ASAP.
    The bug lets someone dodge the limit once after the limit is reached. No big deal, just don't use forgive until I update it tonight.
    __________________
    Twilight Suzuka is offline
    Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
    m4ster
    Senior Member
    Join Date: Mar 2007
    Old 07-08-2008 , 14:53   Re: REGEX Word Filter
    Reply With Quote #6

    if i use*

    "chatpattern" "fuck 'CASELESS'"

    and when i say "fucking", "fucker", "fuck me" etc.. it will be blocked too?
    __________________
    m4ster is offline
    omgiafs
    Junior Member
    Join Date: Jul 2008
    Location: Russia
    Old 07-29-2008 , 03:19   Re: REGEX Word Filter
    Reply With Quote #7

    Good day.

    How long to wait for updated version of this great plugin ?
    Current version gets error on running. Compile successfully with 1.1.0.2427.
    Quote:
    L 07/29/2008 - 15:13:51: [sm_regexfilter.smx] REGEXFilter file partially parsed, please check for errors. Continuing...
    We want working version for [SM] 1.0.3

    Last edited by omgiafs; 07-31-2008 at 00:16.
    omgiafs is offline
    Send a message via ICQ to omgiafs Send a message via Skype™ to omgiafs
    Goatman
    New Member
    Join Date: Aug 2008
    Old 08-13-2008 , 01:28   Re: REGEX Word Filter
    Reply With Quote #8

    Hey, I'm just curious. Do I need to do anything special in the cfg for two-word entries? Or does it need to be single word?
    Goatman is offline
    emotears
    Junior Member
    Join Date: Jun 2008
    Old 08-18-2008 , 00:53   Re: REGEX Word Filter
    Reply With Quote #9

    what do you need in the cfg file to pick up on ip address and email address?
    emotears is offline
    emotears
    Junior Member
    Join Date: Jun 2008
    Old 08-18-2008 , 02:08   Re: REGEX Word Filter
    Reply With Quote #10

    well i guess kind of a moot thing this it doesn't work with the latest svn.

    keep getting this when connecting

    Code:
    Dropped EmoTears from server (x18;)
    

    emotears is offline
    Reply


    Thread Tools
    Display Modes

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 05:35.


    Powered by vBulletin®
    Copyright ©2000 - 2024, vBulletin Solutions, Inc.
    Theme made by Freecode