mIRC Home    About    Download    Register    News    Help

Print Thread
#151895 23/06/06 12:53 AM
Joined: Jun 2006
Posts: 58
S
sas22 Offline OP
Babel fish
OP Offline
Babel fish
S
Joined: Jun 2006
Posts: 58
I need an on text that will react to multiple wildcard words if used..For exapmle I have 3 wildcard texts sucks , gay , and homo.I need a script that will trigger if one of those words are used in a chan message..

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Something like this
Code:
 on *:text:*:#:{
if (gay isin $1-) || (sucks isin $1-) || (homo isin $1-) {
.msg $chan $nick Don't use $v1 in here
}
}
 


That should work and be triggered by someone saying homo but not if they say homosapien (which I'm presuming is what you're wanting). If you don't want any words that contain the key triggers, put an * before and after each word and change the isin to iswm

Joined: Jun 2006
Posts: 58
S
sas22 Offline OP
Babel fish
OP Offline
Babel fish
S
Joined: Jun 2006
Posts: 58
Quote:
Something like this
Code:
 on *:text:*:#:{
if (gay isin $1-) || (sucks isin $1-) || (homo isin $1-) {
.msg $chan $nick Don't use $v1 in here
}
}
 


That should work and be triggered by someone saying homo but not if they say homosapien (which I'm presuming is what you're wanting). If you don't want any words that contain the key triggers, put an * before and after each word and change the isin to iswm
Cant I use the words in a var?

Joined: Aug 2005
Posts: 525
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2005
Posts: 525
Using text isin $1- is effectively the same as using *text* iswm $1-.

In my own opinion it would be more ideal to use regex here. For example:

Code:
on *:TEXT:*:#Channel:{
  if ($regex($1-,/\b((suck|gay|homo)s?)\b/Si)) {
    msg $chan $nick Don't use $regml(1) in here
  }
}


Firstly, the S modifier Strips the text before performing a match and the i modifier performs a case-insensitive match.

This above will match any of the 3 words by themselves, or surrounded by a non-word character on either side (homo! or -gay for example), which is practical. It will not match if the word is surrounded by another word character on either side (e.g. homosapien or omggay). It will also match the plural forms if the s is present, but it doesn't need to be.

In comparison to isin, iswm and $istok, the chance of $regex picking up a false positive is quite non-existant.


Furthermore, using $regex makes it easier to catch variations of words as shown by the following enhancement:

Code:
on *:TEXT:*:#Channel:{
  if ($regex($1-,/\b((suck|gay|h[color:red](?:[/color]o[color:red]|0)[/color]m[color:red](?:[/color]o[color:red]|0)[/color])[color:red]([/color]s[color:red]|z)[/color]?)\b/Si)) {
    msg $chan $nick Don't use $regml(1) in here
  }
}


The word most affected by this change is homo. Instead of matching just the letter 'o', it will now also match if you substitute a '0' (zero) in for either or both of the o's. It will also match if instead of using 's', you use a 'z', once again though the s or z does not need to be present for it to match. These alterations to the code are just me being paranoid smile


Link Copied to Clipboard