RegEx Swear Kick

By Weldon on Jul 27, 2010

A swear kick based on regex, paste in remotes..
Regex based swear filter, that acts on text event. Will match based on the regex list provided and doesn't match against special cases like 'pass', 'grass', ...etc. Instead whole words like 'ass'. Will kick the offender, use it in remotes.
Comment anything.

on @*:TEXT:*:#:{
  if ( $regex($1-, /(bitch|\bass\b|asshole|cunt|cock|dick|fuck|fucking|fucker|motherfucker|nigger|penis|pussy|queer|slut|twat|whore)/Si ) ) {
    kick $chan $nick No Swearing!
  }
}

Comments

Sign in to comment.
Gummo   -  Apr 04, 2011

It seems my test for the \Q..\E was not correct to begin with. Thanks for making me look at it again, jaytea. :P

 Respond  
‌‌‌‌‌‌‌‌   -  Apr 04, 2011

Clueless

 Respond  
‌‌‌‌‌‌‌‌   -  Apr 04, 2011

o.0

 Respond  
jaytea   -  Apr 04, 2011

Gummo, '\' is a literal in between \Q and \E. '\Q\E\E' matches '\' with the second '\E' being superfluous. the rule is simpler than you make it out to be: '\Q' quotes a string up until the very next occurrence of '\E'. everything single thing in between '\Q' and '\E' is treated literally - that is why the simplest way to escape '\E' in the middle of a quote is to use '\E\E\Q', and that is why replacing every occurrence in that way results in a correctly quoted string 100% of the time.

 Respond  
Gummo   -  Apr 04, 2011

Yes, I understand the purpose of escaping the \E to prevent your \Q..\E from breaking. It can also still be broken by a backward slash preceding the \E.
Feel free to test a string "\E " against regex "\Q\E\E" and "\Q\\E\E" which are your options here.

 Respond  
Jethro   -  Apr 04, 2011

Gummo, as you should probably have seen this

$replacecs($me,\E,\E\\E\Q)

flowing in MSL community forums. I didn't make that. I have it borrowed because of its wildly popular availability. :P The \E or \E could exist in a string stored in a text file, so we don't want the regex to be confused.

 Respond  
Gummo   -  Apr 04, 2011

Jethro_ appears to have a misleading regular expression here, but upon closer inspection it seems to be (for the most part) a readability issue.
There's no need to end an escaping \Q...\E, however, to escape something. \E would suffice instead of \E\E\Q.

 Respond  
Warriorii   -  Mar 11, 2011

Jethro_ I wish I could get just code 1/2 as good as you. But I dont think that will ever happen looooool.

Anyway I hope you get your Swearkick working the way u want it too Weldon
Yes Jethro_ it had been removed before i knew what it was for looooool and now I use the \b***\b in my swearkick.

 Respond  
BigSteve   -  Mar 03, 2011

-.- I didnt do it >.<

 Respond  
BigSteve   -  Mar 03, 2011

d i c k

 Respond  
BigSteve   -  Mar 03, 2011

do you mean dick Ford :P

 Respond  
Weldon   -  Mar 02, 2011

O.o i'm good cloud and yourself?
and yes Jethro is right the snippet is pretty much for a few bad words

 Respond  
cloud9   -  Feb 16, 2011

hey Wildon mind having a friend wth three eyes on the face hahaha hw u man

 Respond  
Jethro   -  Dec 23, 2010

Warriorii, the regex is not supposed to kick the word grass. (you must have the \b on both ends of the word ass removed) As the word aѕѕ is intentionally enclosed by the word boundary. I have to say that using regex to match bad words is not an ideal approach. It's okay if you only have a few bad ones to look after.

 Respond  
Warriorii   -  Dec 23, 2010

hmmmmm i tried it and it has the word a$$ in it so i I had my bot type grass and he was kicked.

Is there any out there anywhere that dont do that loooool

 Respond  
Jethro   -  Aug 06, 2010

That website will cost you money for their services.

 Respond  
cmiller100   -  Aug 06, 2010

would it be possible to use http://www.webpurify.com

 Respond  
Jethro   -  Jul 27, 2010

Ever since I've learned about regex, I've come to a conclusion that it is not a best tool for a bad work kicker. Let's you have lots of bad words to add. Your regex string will get very, very long over time. (unless, of course, you use the line break identifier) but that will still look very untidy and you can get your remote file increased in size. The best method I have found is using hash tables with > if ($hfind(badword,$1-,w,1)) {to look for matches.

However, you can still use regex to match bad words stored in a text file. Something like this:

if ($regex($1-,/(?:^| )(\Q $+ $replacecs($read(swear.txt,n,1),\E,\E\\E\Q,$chr(32),\E|\Q) $+ \E)(?= |$)/iS)) {
 Respond  
Weldon   -  Jul 27, 2010

thanks for the comment, i will do more to it

 Respond  
FordLawnmower   -  Jul 27, 2010

Hmm, I just noticed the !@#$. I was talking about this -->> http://www.thinkbabynames.com/meaning/1/Dick
Oh well , strange you can't type one of the most common male names in the english language.

Maybe your regex is fine Weldon. It matches the regex in this box.

 Respond  
FordLawnmower   -  Jul 27, 2010

It needs work. What if your name is dick or your nickname is peacock or cockroach.
Or ... http://www.morewords.com/contains/cock/

 Respond  
Aucun50   -  Jul 27, 2010

RegEx eh? Why the E :)

Also I think /i should be /Si if I'm right the S means to $strip the text of bold, underline and colors.

 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.