mIRC Homepage
Posted By: sahmed01 FIND text in string..HOW ? - 01/06/04 05:06 PM
Hi

Here is what I have in my script

on *:text:*:*:{
if (penis isin $1-) {
if ($nick !isop # ) {
.kick # $nick Abuse detected | break } }

The problem is that it also kicks whoever types pen. How do I fix it so it compares the whole word in $1-

Thanks in advance

Sahmed01



Posted By: Marantz Re: FIND text in string..HOW ? - 01/06/04 06:25 PM
on 1:TEXT:penis*:#: if ($me isop $chan) && ($chan == #yourchanhere) { .kick # $nick Abuse detected }

that post made me chuckle a bit grin
Posted By: NoPleX Re: FIND text in string..HOW ? - 01/06/04 09:13 PM
You can also use this one:

on *:text:*penis*:#:{
if ($me isop $chan) {
kick # $nick Abuse detected
}
}


wink
Posted By: bloupx Re: FIND text in string..HOW ? - 01/06/04 09:24 PM
on *:TEXT:*:#:if ($istok($1-,penis,32)) .raw kick # $nick :abuse detected.
Posted By: Kelder Re: FIND text in string..HOW ? - 01/06/04 09:48 PM
on @*:TEXT:*penis*:#yourchannel: .kick # $nick Abuse detected

The @ replaces the if ($me isop $chan) and the channel is put in the trigger.

Problem is that there might be some words like blahpenisblah that are ok, and it will kick those too. Using regex:

on $@*:TEXT:m/\Wpenis\W/Si:#yourchannel: .kick # $nick Abuse detected

or for other words also (find a guide on regex)
on $@*:TEXT:m/\W(?:penis|nasty|vagina)\W/Si:#yourchannel: .kick # $nick Abuse detected
Posted By: NoPleX Re: FIND text in string..HOW ? - 02/06/04 01:50 AM
Just want to notice you Kelder that your script dont wort this way:

penis bla bla

bla bla penis

It only works this way:

bla penis bla


Just wanted to make a notice! Dont know how to fix it sorry
Posted By: Kelder Re: FIND text in string..HOW ? - 02/06/04 09:47 AM
blush you're right, \W does not match end or start blush

This should do it...
on $@*:TEXT:m/(?<!\w)penis(?!\w)/Si:#yourchannel: .kick # $nick Abuse detected

For multiple words: replace penis with (?:word1|word2|word3)
If you also want to have the word itself use (word1|word2|word3) and you have the offending word in $regml(1)
Posted By: Iori Re: FIND text in string..HOW ? - 02/06/04 10:21 AM
Better would be \b (word boundary)
  • on $@*:text:/\bpenis\b/Si:#yourchanhere:kick # $nick Abuse detected!
Posted By: NoPleX Re: FIND text in string..HOW ? - 02/06/04 10:25 AM
nice Kelder it workes fine now wink
Posted By: Iori Re: FIND text in string..HOW ? - 02/06/04 10:28 AM
Well firstly you got it backwards.
if pen isin $1- <- would match if someone typed penis
  • if $istok($1-,<word>,32) { commands }
    where 32 refers to space (ascii character 32)


on @*:text:*:#:{
  • if $nick isop # { return }
    if $istok($strip($1-),penis,32) { kick # $nick Abuse detected }
    elseif $istok($strip($1-),abuse,32) { kick # $nick Abuse detected }
    elseif $istok($strip($1-),more,32) { kick # $nick Abuse detected }
}
Posted By: Kelder Re: FIND text in string..HOW ? - 02/06/04 11:23 AM
that looks too easy, can't be good :tongue:


OK I'm apparently having some sickness where I completely overlook the obvious stuff frown
© mIRC Discussion Forums