AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   REGEX Word Filter (https://forums.alliedmods.net/showthread.php?t=71867)

Twilight Suzuka 05-26-2008 02:24

REGEX Word Filter
 
6 Attachment(s)
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).

DJ Tsunami 05-26-2008 08:10

Re: REGEX Word Filter
 
Sweet!

JiK 05-26-2008 11:18

Re: REGEX Word Filter
 
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?

Twilight Suzuka 05-26-2008 12:12

Re: REGEX Word Filter
 
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 05-26-2008 17:47

Re: REGEX Word Filter
 
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.

m4ster 07-08-2008 14:53

Re: REGEX Word Filter
 
if i use*

"chatpattern" "fuck 'CASELESS'"

and when i say "fucking", "fucker", "fuck me" etc.. it will be blocked too?

omgiafs 07-29-2008 03:19

Re: REGEX Word Filter
 
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 :)

Goatman 08-13-2008 01:28

Re: REGEX Word Filter
 
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?

emotears 08-18-2008 00:53

Re: REGEX Word Filter
 
what do you need in the cfg file to pick up on ip address and email address?

emotears 08-18-2008 02:08

Re: REGEX Word Filter
 
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;)



Dirton 03-08-2009 16:36

Re: REGEX Word Filter
 
This doesn't work starting sourcemod 1.1, error on loading. Please fix.

Chris-_- 03-08-2009 17:14

Re: REGEX Word Filter
 
He's banned?

Dirton 03-22-2009 13:13

Re: REGEX Word Filter
 
This was like the best plugin in this forum and somebody needed to ban it's creator. :(
I need to filter them IP's bad, is there any alternatives for sourcemod? :)

He's homepage doesn't work, mail doesn't exists. :/

zerak 04-18-2009 18:08

Re: REGEX Word Filter
 
1 Attachment(s)
Might be wrong but this kicked everyplayer as the plugin doesn't return true on player connect. Fix is one liner "return true;" :)

Dirton 05-17-2009 03:05

Re: REGEX Word Filter
 
Thanks! I think it works at last. :)
I will have some quality fun with this thing. :D

'CASLESS' flag doesn't work.
Made classless using alpha expressions [ab], (a | b) doesn’t work with this plugin either.
I was laughing my pants of all this day seeing all them swearing players insult them self with help of this plugin. :D

atmuh 06-05-2009 15:26

Re: REGEX Word Filter
 
I am having a problem where only the first thing in the cfg gets filtered, but nothing after it works. Has anyone else had a similar problem or knows how to fix it?

Twilight Suzuka 06-10-2009 18:27

Re: REGEX Word Filter
 
Quote:

Originally Posted by zerak (Post 808895)
Might be wrong but this kicked everyplayer as the plugin doesn't return true on player connect. Fix is one liner "return true;" :)

Man that was dumb of me. Sorry about that everyone!

The official distribution is now fixed, and I'll be trying to look for any bugs.

Quote:

Originally Posted by atmuh (Post 842440)
I am having a problem where only the first thing in the cfg gets filtered, but nothing after it works. Has anyone else had a similar problem or knows how to fix it?

Sorry, but I cannot replicate this problem.

Sexual Harassment Panda 06-10-2009 19:06

Re: REGEX Word Filter
 
From what I understand, this plugin requires the regex extension to run, and that is not working for me, is there some special way to install the extension or something?

Twilight Suzuka 06-10-2009 19:18

Re: REGEX Word Filter
 
Quote:

Originally Posted by Sexual Harassment Panda (Post 845968)
From what I understand, this plugin requires the regex extension to run, and that is not working for me, is there some special way to install the extension or something?

From what I've seen, the newest version of SourceMod comes with REGEX, so I don't really know how to help. I just installed a fresh copy, and it worked fine.


Also, fixed flags (such as caseless)! Was a silly mistake, forgot a ! before strcmp, so you can now filter all variants of curse words.

atmuh 06-12-2009 07:14

Re: REGEX Word Filter
 
I get this message whenever anyone says anything
07:12:29 L 06/12/2009 - 06:12:30: [SM] Native "ReplaceString" reported: Cannot replace searches of empty strings
07:12:29 L 06/12/2009 - 06:12:30: [SM] Displaying call stack trace for plugin "sm_regexfilter.smx":
07:12:29 L 06/12/2009 - 06:12:30: [SM] [0] Line 157, /home/groups/alliedmodders/forums/files/1/5/9/9/26953.attach::Command_SayHandle()

Twilight Suzuka 06-13-2009 00:21

Re: REGEX Word Filter
 
Show me your config file

Twilight Suzuka 06-14-2009 08:17

Re: REGEX Word Filter
 
Added a power down feature, and a few twiddles.

atmuh 06-16-2009 04:55

Re: REGEX Word Filter
 
here is my config i like to mess with what people say and id like if it worked so i could add a lot more

Code:

"Censor"
{
    "pubfag"
    {
        "chatpattern"        "'pubfag' 'CASELESS'"
        "replace"            "fine sir"
    }
    "umad1"
    {
        "chatpattern"        "'u mad'"
        "chatpattern"        "'umad'"
        "replace"            "I am a complete and utter faggot and should be immediately banned."
    }
        "f10"
    {
        "chatpattern"        "'f10+enter' 'CASELESS'"
        "replace"            "Execute a local disconnect."
    }
}


Jaguar_hl 06-18-2009 11:47

Re: REGEX Word Filter
 
What pattern do I need to use to block IP address spaming on my servers? If I use pattern like "^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$" it does not load because of it lengtht...

Dirton 06-19-2009 19:57

Re: REGEX Word Filter
 
I wrote like this, 1 for IP, the other for DNS:
Code:

"Censor"
{
    "IPfilter"
    {
        "chatpattern"        "\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}:?\d*"
        "replace"        "[adresas pasalintas]"
        "warn"            "IP reklamavimas draudziamas!"
        "action"        "sm_slap #%u 0"
    }
    "DNS1"
    {
        "chatpattern"        "[a-zA-Z0-9]*\.?[a-zA-Z0-9]*\.[a-zA-Z]{2,3}"
        "warn"            "DNS adresu reklamavimas draudziamas!"
        "replace"        "[adresas pasalintas]"
        "action"        "sm_slap #%u 0"
    }
}


Jaguar_hl 06-21-2009 06:39

Re: REGEX Word Filter
 
Thank you!

sciep 07-01-2009 04:55

Re: REGEX Word Filter
 
Hi,

First thanks for this script, but I've got a question;
Does it work with sourcebans? I changed the config that if someone says a disease, he gets a permanent ban, but this doesn't work.

This is the RCON action in the config:
"action" "sm_ban #%u 0 Swearing with diseases"

Thank you for helping.



Here is my config:

"Censor"
{
"Less bad"
{
"chatpattern" "fuck 'CASELESS'"
"chatpattern" "fock 'CASELESS'"
"chatpattern" "fack 'CASELESS'"
"chatpattern" "cunt 'CASELESS'"
"chatpattern" "slet 'CASELESS'"
"chatpattern" "hoer 'CASELESS'"
"chatpattern" "flikker 'CASELESS'"
"chatpattern" "gay 'CASELESS'"
"chatpattern" "homo 'CASELESS'"
"chatpattern" "motherfucker 'CASELESS'"
"chatpattern" "bastard 'CASELESS'"
"chatpattern" "cock 'CASELESS'"
"chatpattern" "cocksucker 'CASELESS'"
"chatpattern" "wanker 'CASELESS'"
"chatpattern" "slut 'CASELESS'"
"replace" "I'm such a noob, because I typ bad words!"
}
"Disease filter"
{
"chatpattern" "cancer 'EXTENDED'"
"chatpattern" "kanker 'EXTENDED'"
"chatpattern" "kenker 'EXTENDED'"
"chatpattern" "tyfus 'EXTENDED'"
"chatpattern" "tering 'EXTENDED'"
"chatpattern" "aids 'EXTENDED'"
"action" "sm_ban #%u 0 Swearing with diseases"
}
}

AiLEX 09-12-2009 16:44

Re: REGEX Word Filter
 
CASELESS flag is not working with non latin symbols

Dirton 09-16-2009 13:49

Re: REGEX Word Filter
 
Could you look into errors like:
Code:

L 09/16/2009 - 20:20:12: [SM] Plugin encountered error 15: Array index is out of bounds
L 09/16/2009 - 20:20:12: [SM] Displaying call stack trace for plugin "sm_regexfilter.smx":
L 09/16/2009 - 20:20:12: [SM]  [0]  Line 77, C:\CSS\cstrike\addons\sourcemod\scripting\sm_regexfilter.sp::OnClientDisconnect()


tazzle0870 09-18-2010 23:03

Re: REGEX Word Filter
 
this filter works great .However I blocked go to hell
so when someone types hello its says plz watch lang. any way around this

SteamKiller 10-05-2010 07:43

Re: REGEX Word Filter
 
Do this plugin a check if chat message come from a real player or advertisements plugin? Because I use the advertisements plugin for post my server's forum address, but do not want players to be able to publish their own advertisements in chat in the form of URL, IP or e-mail.

Atreus 11-02-2010 06:56

Re: REGEX Word Filter
 
It works based around say/sayteam, so yeah it will work fine with your advertisements.

SteamKiller 11-05-2010 16:19

Re: REGEX Word Filter
 
Quote:

Originally Posted by Atreus (Post 1339922)
It works based around say/sayteam, so yeah it will work fine with your advertisements.

Unfortunately it doesn't :(
In console I see my IP is slapped when it tries to chat any IP and no messaje appears in chat area. I did not found in source code where it makes difference between real players and game plugins typing text in chat...

DontWannaName 11-06-2010 02:54

Re: REGEX Word Filter
 
Server chat I believe use the server client which is client 0. Make an if client = 0 then ignore checking for banned words.

Atreus 11-06-2010 11:13

Re: REGEX Word Filter
 
Quote:

Originally Posted by SteamKiller (Post 1342720)
Unfortunately it doesn't :(
In console I see my IP is slapped when it tries to chat any IP and no messaje appears in chat area. I did not found in source code where it makes difference between real players and game plugins typing text in chat...

Well, yeah - if it's TALKING in chat, it's going to catch it. I thought you meant, like, PrintToChatAll type stuff lke tsunami's ads use :/

SteamKiller 11-08-2010 11:15

Re: REGEX Word Filter
 
Quote:

Originally Posted by Atreus (Post 1343203)
Well, yeah - if it's TALKING in chat, it's going to catch it. I thought you meant, like, PrintToChatAll type stuff lke tsunami's ads use :/

To be sure I'll be properly understood:

1. I do use Dj Tsunami's advertisements plugin;
2. I want server-side plugins can talk in chat everything, absolutely no filtering;
3. I do not want that people, including admins, be able to print in chat any IP, e-mail or URL.

I'm not familiar enough with programming to solve this problem alone :(

DarthNinja 11-09-2010 01:21

Re: REGEX Word Filter
 
Quote:

Originally Posted by SteamKiller (Post 1345070)
I'm not familiar enough with programming to solve this problem alone :(

Sounds like a great opportunity to learn!

SteamKiller 11-09-2010 09:44

Re: REGEX Word Filter
 
Quote:

Originally Posted by DarthNinja (Post 1345617)
Sounds like a great opportunity to learn!

Any tips or hints? Other plugins was much easier to modify, but this one turns my head in a brick :) Really, I don't realise how to change it like I posted in #36...

DarthNinja 11-09-2010 23:56

Re: REGEX Word Filter
 
Quote:

Originally Posted by SteamKiller (Post 1345070)
To be sure I'll be properly understood:
1. I do use Dj Tsunami's advertisements plugin;
2. I want server-side plugins can talk in chat everything, absolutely no filtering;
3. I do not want that people, including admins, be able to print in chat any IP, e-mail or URL.
I'm not familiar enough with programming to solve this problem alone :(

  1. This will not filter advertisements because they use PrintToChat. This plugin looks at say/say_team.
  2. If they are correctly written, they will use PrintToChat/PrintToChatAll and this will not be an issue.
  3. I don't see the problem.

The plugin does not seem to check if the client is the server (for rcon say, HLSW, etc). You can fix that by adding this:
PHP Code:

    if (client == 0)
    {
        return 
Plugin_Continue;
    } 

To line 83~

If the chat is from the server console (rcon), it will not filter it.

janpepu 12-16-2010 16:13

Re: REGEX Word Filter
 
hi all

Someone can modify this regex to detect ip in chat?
Code:

"IPfilter"
    {
        "chatpattern"        "\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}:?\d*"
        "replace"        "my ip is private"
        "warn"            "no ip in chat"
            }

is detected:
Code:

lol fan<3<3<3<3
2222222222222222222222222
jtj?647d4787rdgdfdjgdrg4tr'
9-9-9-2 ^^
1y1y1y1y1y1ű
top 100000000
voteban ^2j0j0^4=7...
58555555555555555555555654785589577
o0o0o0o0o

And more

Someone can make a regex for url ?

THx


All times are GMT -4. The time now is 22:04.

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