mIRC Home    About    Download    Register    News    Help

Print Thread
swear code again #189772 11/11/07 08:16 PM
Joined: Oct 2007
Posts: 102
B
bcancer Offline OP
Vogon poet
OP Offline
Vogon poet
B
Joined: Oct 2007
Posts: 102
I want to kick or kick ban the exact word only on open,
exemple: kick sex but not sexy ??

Code:
alias swear { dialog -dmr sweard sweard | %s.chan = #test99 }

dialog sweard {
  title " Swear"
  size -1 -1 342 330
  option pixels
  button "&Close", 1, 205 305 60 20, flat cancel
  list 2, 15 20 309 110, sort size
  box "Swear Words", 3, 5 6 325 153
  button "Add", 4, 100 133 70 20, flat
  button "Remove", 5, 173 133 70 20, flat
  check "Kick Message:", 10, 13 179 84 20
  box "Other Options", 11, 5 156 326 142
  edit "", 12, 99 179 225 20, autohs
  button "Ok", 13, 270 305 60 20, flat ok
  check "Exempt The Ops in the Channel", 14, 13 205 175 10
  check "Exempt The Voices in the Channel", 15, 13 224 185 10
  edit "", 16, 112 238 50 20, autohs
  check "Set Ban Length:", 17, 13 240 99 20
  text "Seconds", 18, 165 240 50 20
  combo 19, 112 265 151 89, edit drop
  text "Select Ban Time", 21, 13 268 99 30
}

on *:dialog:sweard:*:*:{
  if ($devent == init) {
    if ($readini($keke,options,ban)) { did -c $dname 17 }    
    if ($readini($keke,options,message)) { did -c $dname 10 }  
    if ($readini($keke,options,ops)) { did -c $dname 14 }
    if ($readini($keke,options,vops)) { did -c $dname 15 }
    did -a $dname 12 $readini($keke,options,message)    
    if ($readini($keke,options,secs)) { did -c $dname 17 }
    did -a $dname 16 $readini($keke,options,secs)
    did -i $dname 19 0 $readini($keke,options,punish)    
    .dlist 2 swear words  
    did -f $dname 13
    did -a sweard 19 Kick
    did -a sweard 19 Kick and Ban 
    did -a sweard 19 None

  }    
  if ($devent == sclick) {
    if ($did(14).state == 1) { op_c }
    if ($did(15).state == 1) { vo_c }
    if ($did == 4) {
      var %t = $$?="Enter swear word $crlf $+ Separate multiple entries with a comma:"
      if ($numtok(%t,32) > 1) { %t = $replace(%t,$chr(32),$chr(160)) }
      .writeini $keke swear words $iif($readini($keke,swear,words),$+($ifmatch,$chr(44),%t),%t)
      dlist 2 swear words    
    }
    if ($did == 5) {
      var %tmp = $did(2).seltext
      if (%tmp) {
        if ($remtok($readini($keke,swear,words),%tmp,44)) { 
          .writeini $keke swear words $ifmatch 
        }
        else .remini $keke swear words
        .dlist 2 swear words      
      }
    }
    if ($did == 8) {
      var %t = $$?="Enter Channel Name $crlf $+ Separate multiple entries with a comma:"
      if ($chr(32) !isin %t) {
        .writeini $keke exempt chan $iif($readini($keke,exempt,chan),$+($ifmatch,$chr(44),%t),%t)
        dlist 7 exempt chan      
      }
    }
    if ($did == 9) {
      var %tmp = $did(7).seltext
      if (%tmp) {
        if ($remtok($readini($keke,exempt,chan),%tmp,44)) { 
          .writeini $keke exempt chan $ifmatch 
        }
        else .remini $keke exempt chan
        .dlist 7 exempt chan      
      }
    }


    if ($did == 13) {
      ; OK button,flat

      .writeini $keke options kick $iif($did(10).state == 1,$true,$false)
      .writeini $keke options message $iif($did(12),$ifmatch,$readini($keke,options,message))
      .writeini $keke options secs $iif($did(16) isnum 1-,$ifmatch,$readini($keke,options,secs))
      .writeini $keke options ops $iif($did(14).state == 1,$true,$false)
      .writeini $keke options vops $iif($did(15).state == 1,$true,$false)
      .writeini $keke options ban $iif($did(17).state == 1,$true,$false)
      .writeini $keke options punish $iif($did(19),$ifmatch,$readini($keke,options,punish))
    }
  }
}

on *:OPEN:?:*: {
  %swear.punish = $readini($keke,options,punish)) 
  if ($readini($keke,options,ops)) { op_c }
  if ($readini($keke,options,vops)) { vo_c }
  if ($readini($keke,swear,words)) && ($match_text($1-)) {
    if (None isin %swear.punish) { return }    
    if (kick isin %swear.punish) {
      if (ban isin %swear.punish) {
      .ban $+(-ku,$iif($readini($keke,options,secs),$v1,600)) #test99 $nick 2 $readini($keke,options,message)
      }
      else { !kick #test99 $nick $readini($keke,options,message) }
    }
  }
}

alias -l keke return $+(",$scriptdirswear.ini,")

alias -l match_text {
  var %i = 1,%a = $readini($keke,swear,words)
  while ($gettok(%a,%i,44)) {
    var %swear = $+(*,$replace($v1,$chr(160),$chr(32)),*) 
    if ($wildtok($1-,%swear,1,44)) { return $true }
    inc %i
  }
}

alias op_c {
  if ($nick isop %s.chan) { halt }
}

alias vo_c {
  if ($nick isvo %s.chan) { halt }
}
alias -l dlist {
  var %a = 1
  did -r $dname $1
  while ($gettok($readini($keke,$2,$3),%a,44)) {
    did -az $dname $1 $ifmatch
    inc %a
  }
}




 

Last edited by bcancer; 11/11/07 08:16 PM.
Re: swear code again [Re: bcancer] #189815 12/11/07 02:15 AM
Joined: Jun 2006
Posts: 508
D
deegee Offline
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
Try this
Code:
alias -l match_text {
  var %i = 1,%a = $readini($keke,swear,words)
  while ($gettok(%a,%i,44)) {
    var %swear = $+(/\b,$replace($v1,$chr(160),$chr(32)),\b/i)
    if $regex($1-,%swear) { return $true }
    inc %i
  }
}

Re: swear code again [Re: deegee] #189819 12/11/07 02:30 AM
Joined: Oct 2007
Posts: 102
B
bcancer Offline OP
Vogon poet
OP Offline
Vogon poet
B
Joined: Oct 2007
Posts: 102
Samething I still kick frown

Re: swear code again [Re: bcancer] #189821 12/11/07 02:34 AM
Joined: Jun 2006
Posts: 508
D
deegee Offline
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
Then you must also have "sexy" in the list of 'words'...
//echo -a $!regex(something sexy,/\bsex\b/) == $regex(something sexy,/\bsex\b/)
$regex(something sexy,/\bsex\b/) == 0

Re: swear code again [Re: deegee] #189853 12/11/07 04:13 PM
Joined: Oct 2007
Posts: 102
B
bcancer Offline OP
Vogon poet
OP Offline
Vogon poet
B
Joined: Oct 2007
Posts: 102
No I dont have sexy in my list>
words=echoX,kupal,fuckoff,blowjob,suck,whore,bitch,slut,clik,suckmydick,puta,cunt,horny,fucker,pussy,click,fuck,show,sex,biatch,dick,fuckin,gay,seb,cock,bastard,fuckyou,shit,ass,asshole

Re: swear code again [Re: bcancer] #189854 12/11/07 05:04 PM
Joined: May 2007
Posts: 89
T
TropNul Offline
Babel fish
Offline
Babel fish
T
Joined: May 2007
Posts: 89
The while loop is useless if a regular expression is to be used. Here's the method I think of that will/must work.

Code:
alias -l match_text {
  Var %a = $replace($readini($keke,swear,words),$chr(44),$chr(124))
  If $regex($1-,/(\b( %a )\b)/xi) { Return $true } 
  Return $false
}


smile


tropnul
Re: swear code again [Re: bcancer] #189856 12/11/07 05:13 PM
Joined: Aug 2005
Posts: 1,052
L
Lpfix5 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
As deegee posted the earlier script the regex match does work I even tested it myself. I wrote all your words and Hi there sexy does not kick while Hi there wanna have sex does kick.


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Re: swear code again [Re: bcancer] #189872 12/11/07 07:45 PM
Joined: Jun 2006
Posts: 508
D
deegee Offline
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
A better version of the last one wink
Code:
alias -l match_text {
  var %re = /\b( $+ $replace($readini($keke,swear,words),$chr(44),|,$chr(160),$chr(32)) $+ )\b/Si
  return $regex($1-,%re)
}


Edit:
And here's an alias for you to check what matched in a phrase.

/retest <line that triggered the kick>
Code:
alias retest {
  var %re = /\b( $+ $replace($readini($keke,swear,words),$chr(44),|,$chr(160),$chr(32)) $+ )\b/Sig
  echo -a $regsubex($1-,%re,04\t)
}



Last edited by deegee; 12/11/07 07:49 PM.
Re: swear code again [Re: deegee] #189887 12/11/07 09:19 PM
Joined: Oct 2007
Posts: 102
B
bcancer Offline OP
Vogon poet
OP Offline
Vogon poet
B
Joined: Oct 2007
Posts: 102
Sorry guys but nothing seems to work frown

Re: swear code again [Re: bcancer] #189890 12/11/07 09:40 PM
Joined: Jun 2006
Posts: 508
D
deegee Offline
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
And what does the /retest alias show you with whatever line you passed it?

Re: swear code again [Re: deegee] #189892 12/11/07 09:51 PM
Joined: Oct 2007
Posts: 102
B
bcancer Offline OP
Vogon poet
OP Offline
Vogon poet
B
Joined: Oct 2007
Posts: 102
It does nothing,just this:
* /echo: insufficient parameters (line 115, dialog75.op)

Last edited by bcancer; 12/11/07 09:53 PM.
Re: swear code again [Re: bcancer] #189893 12/11/07 09:55 PM
Joined: Jun 2006
Posts: 508
D
deegee Offline
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
Originally Posted By: deegee
And here's an alias for you to check what matched in a phrase.

It's not supposed to kick or ban, its for checking which word(s) matched. wink


/retest <line that triggered the kick> (or didn't trigger..)

Last edited by deegee; 12/11/07 09:59 PM.
Re: swear code again [Re: deegee] #189894 12/11/07 10:07 PM
Joined: Oct 2007
Posts: 102
B
bcancer Offline OP
Vogon poet
OP Offline
Vogon poet
B
Joined: Oct 2007
Posts: 102
Yes it did trigger:
<line that triggered the kick>

Re: swear code again [Re: bcancer] #189895 12/11/07 10:11 PM
Joined: Jun 2006
Posts: 508
D
deegee Offline
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
You must replace <line that triggered the kick> with the actual line that was used. shocked

For example: /retest why dont u use echox script
And it will show you the word(s) that matched in red...
why dont u use echox script

Last edited by deegee; 12/11/07 10:14 PM.
Re: swear code again [Re: deegee] #189896 12/11/07 10:19 PM
Joined: Oct 2007
Posts: 102
B
bcancer Offline OP
Vogon poet
OP Offline
Vogon poet
B
Joined: Oct 2007
Posts: 102
Ya it does show in diff colors then what?

Re: swear code again [Re: bcancer] #189897 12/11/07 10:21 PM
Joined: Jun 2006
Posts: 508
D
deegee Offline
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
Then what didn't work?
Originally Posted By: bcancer
Sorry guys but nothing seems to work
confused

Re: swear code again [Re: deegee] #189900 12/11/07 10:29 PM
Joined: Oct 2007
Posts: 102
B
bcancer Offline OP
Vogon poet
OP Offline
Vogon poet
B
Joined: Oct 2007
Posts: 102
It does not kick or kick ban at all when using your new code.