Regex Swear Kicker

By miniCruzer on Sep 03, 2009

$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) $+ )

Comments

Sign in to comment.
Jethro   -  Jun 07, 2010
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.

Frine  -  Nov 30, 2013

@ Jethro
Can we add exemption menu to this code?

Sign in to comment

jaytea   -  Jun 07, 2010

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.

 Respond  
miniCruzer   -  Jun 07, 2010

Ok, well I just updated it. How does it look now?

 Respond  
Jethro   -  Apr 07, 2010

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.

 Respond  
miniCruzer   -  Apr 07, 2010

Well I had a working copy of this somewhere, and never updated it.

 Respond  
Jethro   -  Feb 13, 2010

"Slubize" is to have a script dialoged. I hereby coin the word. (just kidding...lol)

 Respond  
slub77   -  Feb 13, 2010

slubize? i ain't never done it lol.

 Respond  
Jethro   -  Feb 12, 2010

Sometimes you get very sick and tired to napalize or gooshielize or "slubize" something...especially during the bad days you just don't feel like doing anything but say, "oh screw it!"

 Respond  
Jonesy44   -  Feb 12, 2010

Fix: //mode # +G

 Respond  
slub77   -  Feb 12, 2010

0.0 wow this has had so many comments, yet no one has just fixed it completely 0.0
We need to naperise this, if anyone can reg, napa can lol

 Respond  
Jethro   -  Oct 07, 2009

Gee, another eye-opener. Thanks.

 Respond  
TheImrac   -  Oct 06, 2009

I personally like something along the lines of:

alias swtest {
  If ($hfind(swear,$1-,0,R)) {
    echo -b OMG you swore!!!
  }
}
alias swadd { hadd -m swear $+(/\b,$1,\b/iS) }

/swadd lamers?
/swtest omg you are a lamer!
/swtest No swears in this one...

 Respond  
Jethro   -  Oct 06, 2009

Yeah I don't know why miniCruzer placed \b and $ at the same time, including the g flag, which is needless. You only have to choose to use \b or $ to get the job done.

Gee, thanks gooshie. Much appreciated for the code!

 Respond  
gooshie   -  Oct 05, 2009
$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.

http://xkcd.com/208/

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
}
 Respond  
Jonesy44   -  Oct 05, 2009

Jethro_: Would be more "correct" to use /cuss $1- as opposed to $cuss() since $indets generally mean returns and /cmds obviously are commands. imo.

 Respond  
Jethro   -  Oct 05, 2009

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.

 Respond  
TheProdigY   -  Oct 04, 2009

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
  }
}
 Respond  
Jonesy44   -  Sep 05, 2009

LOL @

Once you go black you never go back! * You were kicked by Bot (:no racial slur!)
 Respond  
Jethro   -  Sep 05, 2009

napa182, it's been awhile, how have you been?

Oh, I totally forgot about the \b anchor. You can use it to match word separately as it is:

/(\bblack\b|\bpussy\b)/iS
Once you go black you never go back! * You were kicked by Bot (:no racial slur!)
 Respond  
pony   -  Sep 05, 2009

swear off

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) }
}

swear end

this oe is mine Enjoy

 Respond  
napa182   -  Sep 05, 2009

yawns

 Respond  
GlobalAnomaly   -  Sep 05, 2009

urban dictionary (which is obv 100% true) begs to differ!

 Respond  
napa182   -  Sep 05, 2009

there is nothing complicated about the scripts i have posted an if you cant read them then go read a few tutts. ;x

 Respond  
GlobalAnomaly   -  Sep 05, 2009

Now to wait for napa to post a complicated code that nobody can read... :P

 Respond  
napa182   -  Sep 05, 2009

lol @ Jethro_ & sunslayer

 Respond  
miniCruzer   -  Sep 04, 2009

Yeah I'm a little new at $regex. I've never even attempted Token Identifiers. Thankyou!!!

 Respond  
Jethro   -  Sep 04, 2009

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.

 Respond  
miniCruzer   -  Sep 04, 2009

@jonesey44 - It only triggers if the sentence starts with the word, but other than that it does solve that problem, yet raises another. bah.

 Respond  
Jethro   -  Sep 04, 2009

Yup, jonssy's got it there by adding a ^ symbol which'll match the start of a string. That piece of regex now ensures the words themselves are matched the way they are...no more or less.

 Respond  
Jonesy44   -  Sep 04, 2009

/^(nigger|motherfucker|pussy|vagina)$/gSi

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.