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!
}
}
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.
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.
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)) {
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.
It needs work. What if your name is dick or your nickname is peacock or cockroach.
Or ... http://www.morewords.com/contains/cock/