$regex swear kicker-I didn't see any other $regex swear kicks, so I thought I'd put one up. Feel free to add more words, I just put the naughty, naughty ones. I'm open to suggestions :)
Change Log
Action Support
Looks for swears in a /me action.
Regex Change
Regex was incorrect. Could not match curses in mid sentence.
Full Sentence
Searches entire sentence for swears, instead of just the first word.
Word Differentiation
Can differentiate between works like ass and assume. Added \b anchor to detect words exactly as specified; scans anywhere in the sentence.
Removed retarded on LOAD event
On-Load advertising function; useless.
Shortened script
Uses more accurate regex, gives proper response to word (useful for debugging), and does not match against ops.
Thank You Jethro_
Thank you joker
ON @$*:TEXT:/\b(niggers?|(?:mother)?fuc?k(?:er)?|pussy|vagina)\b/giS:#:if ($nick !isop $chan) kick $chan $nick Please don't use that kind
of language here. (Auto-response to word: $regml(1) $+ )
ON @$*:ACTION:/\b(niggers?|(?:mother)?fuc?k(?:er)?|pussy|vagina)\b/giS:#:if ($nick !isop $chan) kick $chan $nick Please don't use that
kind of language here. (Auto-response to word: $regml(1) $+ )
on @*:text:*:#:swear $1-
on @*:action:*:#:swear $1-
on @*:notice:*:#:swear $1-
alias -l swear {
var %s = /\b(niggers|(mother)?fuc?k(er)?|pussy|word|word|word|word|word|word|$&
$+ vagina|word|word|word|word|word|word|word|word|word|word|word|word|$&
$+ word|word|word|word|word|word|word|word|word|word|word|word|word)\b/iS
if (($nick !isop #) && ($regex($1-,%s))) {
kick # $nick Please don't use that kind of language here. (Auto-response to word: $regml(1) $+ )
}
}
That'll match motherf-word, f-word and f-word-er. And you can use the link break to divide the regex match if it gets too long.
dysfunctional i'm afraid :P
you can't use a literal : in the matchtext portion of an event header since mirc uses those to separate the fields. it's not sophisticated enough to recognize them as part of the regular expression
if you want to avoid using a capturing subpattern, as in (mother)? instead of (?:mother)?, you can use (?>mother)? as an alternative. (?> ) is called an atomic group and has a very specific function in regex; however if the contents of the group are of a fixed length as yours are, it is practically equivalent to (?: ) in that it won't create a backreference.
One thing about using regex for this is, you're gonna wind up having a big remote with lots and lots of foul words added.
You have to use the line break identifier to break up the regex matching range line by line vertically, until your remote can't take any more adds. (by adding words horizontally will eventually get cut off)
There are various ways to establish a bad-word kicking script, and I've seen a method using a single regex string to match against words added in a text file.
$regex($1-,/^(\bwordA\b|\bwordB\b|\bwordC\b)$/giS)
is functionally equivalent to:
$regex($1-,/^(wordA|wordB|wordC)$/iS)
Both the above expressions match only on wordA OR wordB OR wordC. If any other text preceeds or follows the word it will not match. Even if more exact matches are part of the string. The \b word boundary is unnecessary because with ^ it must begin with wordA OR wordB OR wordC and with $ it must also end with it. The g switch is unnecessary because it can only match a single word anyway. Of course the i switch ignores case and the S switch strips mIRC control codes. Also for a 'swear kicker' the g switch is not really needed because if it matches it does not need to continue searching and go ahead and kick.
Try this for testing purposes:
; usage: /rx wordA wordc blahwordBlah
alias rx {
linesep
if $regex($1-,/^(\bwordA\b|\bwordB\b|\bwordC\b)$/giS) { echo -a original: $1- }
if $regex($1-,/^(wordA|wordB|wordC)$/iS) { echo -a exact match: $1- }
if $regex($1-,/(\bwordA\b|\bwordB\b|\bwordC\b)/giS) {
var %i 1,%r
while $regml(%i) {
%r = %r $v1
inc %i
}
echo -a word match: %r
}
if $regex($1-,/(wordA|wordB|wordC)/giS) {
var %i 1,%r
while $regml(%i) {
%r = %r $v1
inc %i
}
echo -a string match: %r
}
linesep
}
TheProdigY, I'll recommend this:
on @*:TEXT:*:#:$cuss($1-)
on @*:ACTION:*:#:$cuss($1-)
on @*:NOTICE:*:#:$cuss($1-)
alias -l cuss {
tokenize 32 $strip($1-)
var %cuss = 1, %swear = $me @#$ black nigga negro niggah n1gger kike !@#$ !@#$ !@#$ SyracuseChat
while ($gettok(%swear,%cuss,32)) {
if ($findtok($1-,$v1,1,32)) {
kick $chan $nick Please don't use that kind of language here.
}
inc %cuss
}
}
This way you cover the text, action and notice event together.
Also for an on ACTION just add below the on TEXT...
on @*:ACTION:*:#: {
var %cuss = 1, %swear = $me cunt nigger nigga negro niggah n1gger kike motherfuck motherfucker motherfucking SyracuseChat
while ($gettok(%swear,%cuss,32)) {
if ($findtok($strip($1-),$v1,1,32)) {
kick $chan $nick Please don't use that kind of language here.
}
inc %cuss
}
}
on :text::#: {
if ($me !isop $chan) halt
if (($istok($1-,fuck,32) == $true) || ($istok($1-,BITCH,32) == $true)) || (($istok($1-,cunt,32) == $true)) || (($istok($1-,pussy,32) == $true)) || (($istok($1-,wanker,32) == $true)) || (($istok($1-,cock,32) == $true)) || (($istok($1-,nigger,32) == $true)) {
if ($nick isowner $chan) goto test
if ($nick isop $chan) goto test
if ($readini(protection.ini, $nick, swear) != true) {
.msg $nick ( $nick ) Please do not swear on $chan $+ ! U Will Be Ban next time
.msg $chan Profanity Not Allowed $nick Plz Stop With It!
writeini protection.ini $nick swear true
.timer 1 30 /remini protection.ini $nick swear
halt
}
else {
auser swear $address($nick,1) :swearing $nick $adate $time
access # add deny ! $+ $$ial($nick $+ ,1).addr 15 $Nick swear
kick # $nick Profanity Not Allowed! ban 15 min | halt
}
:test {
.msg $nick ( $nick ) we need to set the example plz $nick }
}
}
on :ACTION::#: {
if ($me !isop $chan) halt
if (($istok($1-,fuck,32) == $true) || ($istok($1-,BITCH,32) == $true)) || (($istok($1-,cunt,32) == $true)) || (($istok($1-,pussy,32) == $true)) || (($istok($1-,wanker,32) == $true)) || (($istok($1-,cock,32) == $true)) || (($istok($1-,nigger,32) == $true)) {
if ($nick isowner $chan) goto test
if ($nick isop $chan) goto test
if ($readini(protection.ini, $nick, swear) != true) {
.msg $nick ( $nick ) Please do not swear on $chan $+ ! U will be band next time
.msg $chan Profanity Not Allowed $nick Plz stop with it!
writeini protection.ini $nick swear true
.timer 1 30 /remini protection.ini $nick swear
halt
}
else {
auser swear $address($nick,1) :swearing $nick $adate $time
access # add deny ! $+ $$ial($nick $+ ,1).addr 15 $Nick swear
kick # $nick Profanity Not Allowed! ban 15 min | halt
}
:test {
.msg $nick ( $nick ) we need to set the example plz $nick }
}
}
on swear:join:#:{
if $me isop $chan { msg $chan welcome back $nick , you was removed for swearing, plz dont let it happen again Ty. | ruser swear $address($nick,1) }
}
this oe is mine Enjoy
Actually I have to acknowledge the fact that using regex to kick bad words isn't 100% foolproof. miniCruzer, you might wanna try this:
on @*:TEXT:*:#: {
var %cuss = 1, %swear = badword1 badword2 badword3 badword4
while ($gettok(%swear,%cuss,32)) {
if ($findtok($strip($1-),$v1,1,32)) {
kick $chan $nick Please don't use that kind of language here.
}
inc %cuss
}
}
This shall match exactly the way words are and anywhere in a sentence.
@ Jethro
Can we add exemption menu to this code?