mIRC Homepage
Posted By: skovicniq help on $regex - 04/12/07 04:17 AM
Code:
 
if ($regex($1-,/(#|http://|www.|.com|.net|.org)/Si)) spam
 if ($regex($1-,/\b(fuck|suck)\b/Si)) swear


Is there a way that i can add an option to add or remove spam/swear words .. like using level we can add or remove by .auser @ .ruser .. Thanks

alias addspamword { bla bla }
alias remspamword { bla bla }
alias addswearword { bla bla }
alias remswearword { bla bla }
Posted By: TropNul Re: help on $regex - 04/12/07 08:43 AM
It is possible as you're using the alternating metachar '|' in the regexps. So, just by using some of mIRC's $*tok identifiers with $chr(124) as separating character will do it.

Here's a method.

Code:
menu * {
  -
  Detector
  .Add SpamWord:Detec.Var spamadd $$?='Enter the spam word to be added'
  .Remove SpamWord:Detec.Var spamdel $$?='Enter the spam word to be removed'
  .Add SwearWord:Detec.Var swearadd $$?='Enter the swear word to be added'
  .Remove SwearWord:Detec.Var sweardel $$?='Enter the swear word to be removed'
  -
}

Alias Detec.Main { 
  If %Det.Spam && $regex($1-,/( %Det.Spam )/Six) { Echo -ast PASSED -> $regml(1) }
  ElseIf %Det.Swear && $regex($1-,/\b( %Det.Swear )\b/Six) { Echo -ast PASSED -> $regml(1) }
}

Alias Detec.Show {
  Tokenize 124 $1-
  If ($0 > 0) {
    Echo -ast Here are the words currently saved:
    Echo -ast -> $*
  }
  Else { Echo -ast The variable is now empty! }
}

Alias Detec.Var {
  If ($1 == spamadd) {
    If !%Det.Spam { Set %Det.Spam $2 }
    Else { Set %Det.Spam %Det.Spam $+ $chr(124) $+ $2 }
    Detec.Show %Det.Spam
  }
  ElseIf ($1 == spamdel) {
    If !%Det.Spam { Echo -ast There are no Spam words already saved! }
    Else { Set %Det.Spam $remtok(%Det.Spam,$2,1,124) | Detec.Show %Det.Spam }
  }
  ElseIf ($1 == swearadd) {
    If !%Det.Swear { Set %Det.Swear $2 }
    Else { Set %Det.Swear %Det.Swear $+ $chr(124) $+ $2 }
    Detec.Show %Det.Swear
  }
  ElseIf ($1 == sweardel) {
    If !%Det.Swear { Echo -ast There are no Swear words already saved! }
    Else { Set %Det.Swear $remtok(%Det.Swear,$2,1,124) | Detec.Show %Det.Swear }
  }
}


Of course, there are other methods. But this one functions.

Cordialement
Posted By: BanJirian Re: help on $regex - 06/12/07 05:03 AM
"Enter the spam word to be added" instead of 'Enter the spam word to be added'

i changed $1-,/( $+ %det.* $+ ). Then it works

by the way tropnul, i tried the codes but if %det.* is empty or !%det.* .. it will detect all words .. let say somebody msg "abc", then that person will be kicked. But if %det.* was not empty its works fine. Sorry if im wrong.
Posted By: TropNul Re: help on $regex - 06/12/07 06:50 AM
That's bizarre because in

Code:
Alias Detec.Main { 
  If %Det.Spam && $regex($1-,/( %Det.Spam )/Six) { Echo -ast PASSED -> $regml(1) }
  ElseIf %Det.Swear && $regex($1-,/\b( %Det.Swear )\b/Six) { Echo -ast PASSED -> $regml(1) }
}


The first condition in each case, i.e, "If %Det.Spam" and "ElseIf %Det.Swear" makes that it only reacts whenever there is something in the variable.

Through the tests I've made on my pc, it doesn't react at all if there is nothing in the variable. It can't detect anything if the variable doesn't even exist. That issue sounds weird to me.

And for the first issue, ( "Enter the spam word to be added" instead of 'Enter the spam word to be added' ), it's an error. Of course, it should be double quotes. wink

Cordialement
© mIRC Discussion Forums