aIRC — File Browser

aIRCv0.8.69 / aIRCv0.8.69 / script / protec.mrc

protec.mrc — 27.83 KB — Download this file

;/**********************************************************************
; *
; * aIRC
; * Prot routines
; *
; **********************************************************************/
;

;;
;
; $_flood.main(inc1,inc2,max1,max2,seconds,variable,flags)
;   l - don´t trigger if lagged
;   u - don't unset variable
;
;
alias _flood.main {
  if ($5 <= 0) { return }
  tokenize 32 $1-5 % $+ $6 $7
  var %var = [ [ $6 ] ] ,%var1 = $gettok(%var,1,32),%var2 = $gettok(%var,2,32),%t = $ctime,%ub = %t - $5,%ifmatch
  while ($gettok(%var1,1,46) != $null) {
    if ($ifmatch < %ub) { var %var1 = $deltok(%var1,1,46),%var2 = $deltok(%var2,1,43) }
    else { break }
  }
  if ($calc($len(%var1) + $len(%var2)) > 900) { var %var1 = $gettok(%var1,2-,46),%var2 = $calc($gettok(%var2,1-2,43)) $+ + $+ $gettok(%var2,3-,43) }
  var %var1 = %var1 $+ $str(. [ $+ [ %t ] ] ,$1),%var2 = %var2 $+ $str(+ [ $+ [ $2 ] ] ,$1)
  set -u $+ $calc($5 + 1) $6 %var1 %var2
  if (l isin $7) && (%_nofloodtlag > 0) && (%.lag.current > %_nofloodtlag) { return }
  if ($3) && ($numtok(%var1,46) >= $3) {
    %ifmatch = $ifmatch
    if (d !isin $7) { unset $6 }
    return %ifmatch $calc($ctime - $gettok(%var1,1,46)) $calc(%var2)
  }
  if ($4) && ($calc(%var2) >= $4) {
    %ifmatch = $ifmatch
    if (d !isin $7) { unset $6 }
    return $numtok(%var1,46) $calc($ctime - $gettok(%var1,1,46)) %ifmatch
  }
}
; $_flood2(seconds,var)
; 1 command every $1 seconds (var = $2)
alias _flood2 {
  tokenize 32 $1 % $+ $2
  var %var = [ [ $2 ] ]
  if (%var) { return 1 }
  set -u $+ $1 $2 1
  return 0
}
;;
;
; $_flood.personal(type,typenum,inc1,inc2,$nick,$fulladdress,varID,flags)
;   t = don't punish
;
;   1 putext
;   2 punotice
;   3 puinvite
;   4 puctcp
;   5 pudcc
;   6 puquery
;   7 puchat
;   8 pufserve
;
alias _flood.personal {
  var %l = $gettok($hget(_aircprot,personal),$2,32),%result
  if ($gettok(%l,1,46)) {
    _flood.main $3 $4 $gettok(%l,2,46) $gettok(%l,3,46) $gettok(%l,4,46) Ø $+ $1 $+ ! $+ $7 $8
    if ($result) {
      %result = $ifmatch
      var %count = $gettok(%result,1,32),%seconds = $gettok(%result,2,32),%countb = $gettok(%result,3,32),%max = $gettok(%l,2,46),%maxb = $gettok(%l,3,46)
      if (t !isin $8) { _dummy $_triggered($1,$null,$_nospaces(¶,$1,!,$7),$nick,$site,$address,$fulladdress,%count,%max,%seconds,%countb,%maxb) }
      return %result
    }
  }
}
;
;;
;
; $_flood.personalbotnet(type,typenum,inc1,inc2,flags)
;   t = don't punish
;
;   1 pbtext
;   2 pbnotice
;   3 pbinvite
;   4 pbctcp
;   5 pbdcc
;   6 pbquery
;
alias _flood.personalbotnet {
  var %l = $gettok($hget(_aircprot,personalbotnet),$2,32),%result
  if ($gettok(%l,1,46)) {
    _flood.main $3 $4 $gettok(%l,2,46) $gettok(%l,3,46) $gettok(%l,4,46) Ø $+ $1 $5
    if ($result) {
      %result = $ifmatch
      var %count = $gettok(%result,1,32),%seconds = $gettok(%result,2,32),%countb = $gettok(%result,3,32),%max = $gettok(%l,2,46),%maxb = $gettok(%l,3,46)
      if (t !isin $5) { _dummy $_triggered($1,$null,$_nospaces(¶,$1),$null,$null,$null,$null,%count,%max,%seconds,%countb,%maxb) }
      return %result
    }
  }
}
;;
;
; $_flood.chan(type,typenum,inc1,inc2,$nick,$fulladdress,varID,$chan,flags)
;   t = don't punish
;
alias _flood.chan {
  var %l = $_prot.chansetting($1,$2,1-,$8),%result
  if ($gettok(%l,1,46)) {
    if (%c.nocounter1) {
      %l = $puttok(%l,2,0,46)
      unset %c.nocounter1
    }
    _flood.main $3 $4 $gettok(%l,2,46) $gettok(%l,3,46) $gettok(%l,4,46) Ø $+ $1 $+ ! $+ $7 $+ $8 $9
    if ($result) {
      %result = $ifmatch
      var %count = $gettok(%result,1,32),%seconds = $gettok(%result,2,32),%countb = $gettok(%result,3,32),%max = $gettok(%l,2,46),%maxb = $gettok(%l,3,46)
      if (t !isin $9) { _dummy $_triggered($1,$8,$_nospaces(¶,$1,!,$7,$8),$5,$gettok($6,2,64),$gettok($6,2,33),$6,%count,%max,%seconds,%countb,%maxb) }
      return %result
    }
  }
}
;
;;
;
; $_flood.chanbotnet(type,typenum,inc1,inc2,$chan,flags)
;   t = don't punish
;
alias _flood.chanbotnet {
  var %l = $_prot.chanbotnetsetting($1,$2,1-,$5),%result
  if ($gettok(%l,1,46)) {
    _flood.main $3 $4 $gettok(%l,2,46) $gettok(%l,3,46) $gettok(%l,4,46) Ø $+ $1 $+ $5 $6
    if ($result) {
      %result = $ifmatch
      var %count = $gettok(%result,1,32),%seconds = $gettok(%result,2,32),%countb = $gettok(%result,3,32),%max = $gettok(%l,2,46),%maxb = $gettok(%l,3,46)
      if (t !isin $6) { _dummy $_triggered($1,$5,$_nospaces(¶,$1,$5),$null,$null,$null,$null,%count,%max,%seconds,%countb,%maxb) }
      return %result
    }
  }
}
;
;;
;
; $_prot.chansetting(type,typenum,typenumtok,[channel])
;
;    1 cutext
;    2 cunotice
;    3 cucolour
;    4 cuascii
;    5 cucaps
;    6 curepeat
;    7 cuadvert
;    8 cuswear
;    9 cuctcp
;   10 cunsctcp
;   11 cudccctcp
;   12 cumdeop
;   13 cumkick
;   14 cumban
;   15 cudmodel
;   16 cudmodek
;   17 cudmodei
;   18 cunethack
;   19 cubitchmode
;   20 cujoinpart
;   21 cunick
;   22 cumodetopic
;   23 cuclones
;   24 cubadnick
;   25 cubadident
;   26 exemptops
;   27 exemptvoiced
;   28 cudeoprevenge
;   29 cukickrevenge
;   30 cuenforcebans
;   31 cuonmedeop
;   32 cuonmekick
;   33 cuonmeban
;   34 cunoconsctcp
;
alias _prot.chansetting {
  if ($4) {
    if ($gettok($hget(_aircprot,chan_ [ $+ [ $4 ] ] ),$2,32) != $null) { return $gettok($ifmatch,$3,46) }
  }
  return $gettok($gettok($hget(_aircprot,chan_global),$2,32),$3,46)
}
;
;;
;
; $_prot.chanbotnetsetting(type,typenum,typenumtok,[channel])
;
;
;    1 cbtext
;    2 cbnotice
;    3 cbctcp
;    4 cbjoinpart
;    5 cbnick
alias _prot.chanbotnetsetting {
  if ($4) {
    if ($gettok($hget(_aircprot,botnet_ [ $+ [ $4 ] ] ),$2,32) != $null) { return $gettok($ifmatch,$3,46) }
  }
  return $gettok($gettok($hget(_aircprot,botnet_global),$2,32),$3,46)
}
;
alias _prot.bugnick {
  if ($istok($_prot.bugnick.nicks,$nick,32)) {
    error.a Nick Exploit from $nick 
    halt
  }
}
alias _prot.bugnick.nicks { return lpt1 lpt2 com1 com2 com3 com4 ps1 ps2 }

;
;;
;
; $_prot.isprot([chan],[op/voice protection?])
;
alias _prot.isprot {
  if (%++service) || (b isincs %++flags) || ($nick == $me) || (f isincs %++flags) || (m isincs %++flags) || (n isincs %++flags) || (($_rchini(dontkickops,$1)) && (o isincs %++flags)) { return 1 }
  if ($1) && ($2) {
    if ($_prot.chansetting(exemptops,26,1,$1)) && ($nick isop $1) { return 1 }
    if ($_prot.chansetting(exemptvoiced,27,1,$1)) && ($nick isvo $1) { return 1 }
  }
  return 0
}

ON *:TEXT:*:?:{ _prot.privtext $1- }
ON *:ACTION:*:?:{ _prot.privtext $1- }
alias _prot.privtext {
  var %tmp
  if ($_prot.isprot($null,0)) { return }
  %tmp = $_flood.personalbotnet(pbtext,1,1,$len($1-),_l_)
  %tmp = $_flood.personal(putext,1,1,$len($1-),$nick,$fulladdress,%++maskclon,_l_)
}
ON *:NOTICE:*:?:{
  var %tmp
  if ($_prot.isprot($null,0)) { return }
  %tmp = $_flood.personalbotnet(pbnotice,2,1,$len($1-),_l_)
  %tmp = $_flood.personal(punotice,2,1,$len($1-),$nick,$fulladdress,%++maskclon,_l_)
}
ON *:INVITE:#:{
  var %tmp
  if ($_prot.isprot($null,0)) { return }
  %tmp = $_flood.personalbotnet(pbinvite,3,1,0,_l_)
  %tmp = $_flood.personal(puinvite,3,1,0,$nick,$fulladdress,%++maskclon,_l_)
}
CTCP *:DCC:?:{
  var %tmp
  if ($_prot.isprot($null,0)) { return }
  %tmp = $_flood.personalbotnet(pbdcc,5,1,0,_l_)
  %tmp = $_flood.personal(pudcc,5,1,0,$nick,$fulladdress,%++maskclon,_l_)
}
CTCP *:*:?:{ _prot.privctcp $1- }
alias -l _prot.privctcp {
  var %tmp
  if ($_prot.isprot($null,0)) { return }
  %tmp = $_flood.personalbotnet(pbctcp,4,1,0,_l_)
  %tmp = $_flood.personal(puctcp,4,1,0,$nick,$fulladdress,%++maskclon,_l_)
}
ON ^*:OPEN:?: {
  var %tmp
  if ($_prot.isprot($null,0)) { return }
  %tmp = $_flood.personalbotnet(pbquery,6,1,0,_l_)
  %tmp = $_flood.personal(puquery,6,1,0,$nick,$fulladdress,%++maskclon,_l_)
}
ON *:CHAT:*:{ var %tmp = $_flood.personal(puchat,7,1,$len($1-),$nick,$null,$nick,0) }
ON *:SERV:*:{ var %tmp = $_flood.personal(pufserve,8,1,$len($1-),$nick,$null,$nick,0) }
ON *:CTCPREPLY:*:{
  if ($_ischan($target)) { _prot.chanctcp $target $1- }
  else { _prot.privctcp }
}
;
;;
;
ON *:TEXT:*:#:{ _prot.chantext $1- }
ON *:ACTION:*:#:{ _prot.chantext $1- }
alias _prot.chantext {
  var %tmp
  if ($target !ischan) || ($_prot.isprot($chan,1)) { return }
  if (k isincs %++flags) { _autokickloser %++handle $nick $chan }
  %tmp = $_flood.chanbotnet(cbtext,1,1,$len($1-),$chan,_l_)
  %tmp = $_flood.chan(cutext,1,1,$len($1-),$nick,$fulladdress,%++maskclon,$chan,_l_)
  if ($me !isop $chan) { return }
  _prot.chantextnotice $1-
}
ON *:NOTICE:*:#:{
  var %tmp
  if ($target !ischan) || ($_prot.isprot($chan,1)) { return }
  if (k isincs %++flags) { _autokickloser %++handle $nick $chan }
  %tmp = $_flood.chanbotnet(cbnotice,2,1,$len($1-),$chan,_l_)
  %tmp = $_flood.chan(cunotice,2,1,$len($1-),$nick,$fulladdress,%++maskclon,$chan,_l_)
  if ($me !isop $chan) { return }
  _prot.chantextnotice  $1-
}
alias _prot.chantextnotice {
  var %len = $len($1-),%tmp,%strip = $strip($1-)
  if (%len !isnum) || (%len == 0) { return }

  %tmp = $_prot.badident($chan,$nick,$fulladdress,$_nospaces(¶,cubadident,!,%++maskclon,$chan))

  ; cucolour
  var %s = $_prot.chansetting(cucolour,3,1-,$chan),%n,%m,%t
  if ($gettok(%s,1,46)) {
    var %n = $calc(%len - $len(%strip)),%m = $gettok(%s,2,46)
    if (%m) && (%n >= %m) { %tmp = $_triggered(cucolour,$chan,$_nospaces(¶,cucolour,!,%++maskclon,$chan),$nick,$site,$address,$fulladdress,%n,%m,0,0,0) }
    else {
      %c.nocounter1 = 1
      %tmp = $_flood.chan(cucolour,3,0,%n,$nick,$fulladdress,%++maskclon,$chan,_l_)
    }
  }

  ; cuascii
  var %s = $_prot.chansetting(cuascii,4,1-,$chan),%n,%m = $gettok(%s,2,46),%t = $gettok(%s,4,46)
  if ($gettok(%s,1,46)) && (%len >= %t) {
    if ($round($calc($len($remove(%strip,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,1,2,3,4,5,6,7,8,9,$chr(32),$chr(44),$chr(91),$chr(93),$chr(40),$chr(41),$chr(123),$chr(125),~,!,@,$chr(35),$,%,&,*,-,_,=,+,;,:,',",<,>,.,?,¿,/,\,,,,,)) * 100 / %len),0) >= %m) { %tmp = $_triggered(cuascii,$chan,$_nospaces(¶,cuascii,!,%++maskclon,$chan),$nick,$site,$address,$fulladdress,$ifmatch,%m,0,0,0) }
  }

  ; cucaps
  var %s = $_prot.chansetting(cucaps,5,1-,$chan),%n,%m = $gettok(%s,2,46),%t = $gettok(%s,4,46)
  if ($gettok(%s,1,46)) && (%len >= %t) {
    if ($round($calc((%len - $len($removecs($1-,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,Ñ))) / (%len - $len($remove($1-,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,Ñ))) * 100),0) >= %m) { %tmp = $_triggered(cucaps,$chan,$_nospaces(¶,cucaps,!,%++maskclon,$chan),$nick,$site,$address,$fulladdress,$ifmatch,%m,0,0,0) }
  }

  ; curepeat
  var %s = $_prot.chansetting(curepeat,6,1-,$chan),%n,%m,%v = Ørepeat. $+ $nick $+ $chan,%t = % [ $+ [ %v ] ]
  if ($gettok(%s,1,46)) {
    if (%t == %strip) && ($_flood.chan(curepeat,6,1,0,$nick,$fulladdress,%++maskclon,$chan,_l_)) { unset %Ørepeat. $+ $nick $+ $chan }
    else { set -u [ $+ [ $gettok(%s,4,46) ] ] %Ørepeat. $+ $nick $+ $chan %strip }
  }

  ; cuadvert
  var %s,%n,%m,%t
  if ($_prot.chansetting(cuadvert,7,1,$chan)) {
    if ($hget(_aircprot,cuadvert_ [ $+ [ $chan ] ] ) != $null) { %c.prot.iswmatch = $ifmatch }
    else { %c.prot.iswmatch = $hget(_aircprot,cuadvert_global) }
    if (%c.prot.iswmatch != $null) { %tmp = $_prot.iswmatch(cuadvert,$chan,$_nospaces(¶,cuadvert,!,%++maskclon,$chan),$nick,$site,$address,$fulladdress,254,1,$1-) }
    unset %c.prot.iswmatch
  }

  ; cuswear
  var %s,%n,%m,%t,%z
  if ($_prot.chansetting(cuswear,8,1,$chan)) {
    if ($hget(_aircprot,cuswear_ [ $+ [ $chan ] ] ) != $null) { %c.prot.iswmatch = $ifmatch }
    else { %c.prot.iswmatch = $hget(_aircprot,cuswear_global) }
    if (%c.prot.iswmatch != $null) { %tmp = $_prot.iswmatch(cuswear,$chan,$_nospaces(¶,cuswear,!,%++maskclon,$chan),$nick,$site,$address,$fulladdress,254,1,$1-) }
    unset %c.prot.iswmatch
  }
}
;
;;
;
; $_prot.iswmatch(type,channel,var,nick,site,address,fulladdress,token,strip,parms)
;
alias _prot.iswmatch {
  var %m = %c.prot.iswmatch,%t,%i,%z
  unset %c.prot.iswmatch
  if ($9) { %t = * $strip($replace($10,$chr(44), ,_, ,-, ,$chr(40), ,$chr(41), ,[, ,], ,¡, ,!, ,¿, ,?, ,", ,., , ,$chr(32))) * }
  else { %t = * $10 * }
  %i = $numtok(%m,$8)
  while (%i) {
    %z = $gettok(%m,%i,$8)
    if ($gettok(%z,1,32) != *) { %z = * %z }
    if ($gettok(%z,$numtok(%z,32),32) != *) { %z = %z * }
    if (%z iswm %t) || (%z iswm * $10 *) {
      _dummy $_triggered($1,$2,$3,$4,$5,$6,$7,$gettok(%m,%i,$8),0,0,0,0)
      return 1
    }
    dec %i
  }
  return 0
}
CTCP *:*:#:{
  var %tmp
  _prot.chanctcp $chan $1-
  if ($result) { return }
  if ($me !isop $chan) { return }
  if ($_prot.chansetting(cunsctcp,10,1,$chan)) {
    var %m
    if ($hget(_aircprot,cunsctcp_ [ $+ [ $chan ] ] ) != $null) { %m = $ifmatch }
    else { %m = $hget(_aircprot,cunsctcp_global) }
    if (%m != $null) && ($istok(%m,$1,44) == $false) { %tmp = $_triggered(cunsctcp,$chan,$_nospaces(¶,cunsctcp,!,%++maskclon,$chan),$nick,$site,$address,$fulladdress,$upper($1),$2-,0,0,0) }
  }
  if ($1 == dcc) && ($_prot.chansetting(cudccctcp,11,1,$chan)) { %tmp = $_triggered(cudccctcp,$chan,$_nospaces(¶,cudccctcp,!,%++maskclon,$chan),$nick,$site,$address,$fulladdress,$upper($2),0,0,0,0) }
}
; /_prot.chanctcp channel text
alias -l _prot.chanctcp {
  var %tmp
  if ($_prot.isprot($1,1)) { return 1 }
  if (k isincs %++flags) { _autokickloser %++handle $nick $chan }
  if ($_prot.chansetting(cunoconsctcp,34,1,$chan)) {
    var %toks
    if ($hget(_aircprot,cunoconsctcp_ [ $+ [ $chan ] ] ) != $null) { %toks = $ifmatch }
    else { %toks = $hget(_aircprot,cunoconsctcp_global) }
    if (%toks != $null) && ($istok(%toks,$2,32)) { return 0 }
  }
  %tmp = $_flood.chanbotnet(cbctcp,3,1,0,$1,_l_)
  %tmp = $_flood.chan(cuctcp,9,1,0,$nick,$fulladdress,%++maskclon,$1,_l_)
}
ON *:DEOP:#:{ _prot.ondeop }
ON *:DEOWNER:#:{ _prot.ondeop }
alias _prot.ondeop {
  if ($nick == $opnick) { return }
  var %isprot = $_prot.isprot($chan,0)
  if ($opnick == $me) {
    if ($_not(%isprot)) && ($_prot.chansetting(cudeoprevenge,28,1,$chan)) { set %Øcudeoprevenge. $+ $chan $nick $ctime }
    if ($_prot.chansetting(cuonmedeop,31,1,$chan)) {
      if ($_prot.chansetting(cuonmedeop,31,5,$chan)) { _bot.use 0 opme $chan }
      if ($_not(%isprot)) {
        if ($_prot.chansetting(cuonmedeop,31,3,$chan)) { _prot.doitbottie!doit! kick $chan $nick $me }
        elseif ($_prot.chansetting(cuonmedeop,31,2,$chan)) { _prot.doitbottie!doit! deop $chan $nick }
        if ($_prot.chansetting(cuonmedeop,31,4,$chan)) { _prot.doitbottie!doit! ban $chan $nick }
      }
    }
  }
  if ($me !isop $chan) || (%isprot) { return }
  if ($_rchini(revenge,$chan)) && ((($_rchini(protectfriends,$chan)) && (f isincs %++flags2)) || (($_rchini(protectops,$chan)) && (o isincs %++flags2))) { deop $chan $nick }
  _prot.mdeop
}
alias _prot.mdeop { var %tmp = $_flood.chan(cumdeop,12,1,0,$nick,$fulladdress,%++maskclon,$chan,_l_) }
ON *:KICK:#:{
  if ($nick == $knick) { return }
  var %isprot = $_prot.isprot($chan,0),%tmp
  if ($knick == $me) {
    if ($_not(%isprot)) && ($_prot.chansetting(cukickrevenge,29,1,$chan)) { set %Øcukickrevenge. $+ $chan $nick $ctime $1- }
    if ($_prot.chansetting(cuonmekick,32,1,$chan)) {
      if ($_prot.chansetting(cuonmekick,32,5,$chan)) { _bot.use 0 unbanme $chan }
      if ($_prot.chansetting(cuonmekick,32,6,$chan)) { _bot.use 0 inviteme $chan }
      if ($_not(%isprot)) {
        if ($_prot.chansetting(cuonmekick,32,3,$chan)) { _prot.doitbottie!doit! kick $chan $nick $me }
        elseif ($_prot.chansetting(cuonmekick,32,2,$chan)) { _prot.doitbottie!doit! deop $chan $nick }
        if ($_prot.chansetting(cuonmekick,32,4,$chan)) { _prot.doitbottie!doit! ban $chan $nick }
      }
    }
  }
  if (%isprot) { return }
  if ($me isop $chan) {
    if ($_rchini(revenge,$chan)) && ((($_rchini(protectfriends,$chan)) && (f isincs %++flags2)) || (($_rchini(protectops,$chan)) && (o isincs %++flags2))) {
      _puthelp $nick & _qnotice $nick $_evaltext($replace($_defmsg(dontkickfriend),<NICK>,$knick))
      deop $chan $nick
    }
    %tmp = $_flood.chan(cumkick,13,1,0,$nick,$fulladdress,%++maskclon,$chan,_l_)
    if ($knick isop $chan) { _prot.mdeop }
  }
}
ON *:BAN:#:{
  var %unban,%unbanned,%i = %+onban.num,%m,%isprot = $_prot.isprot($chan,0),%msg,%enforce = $_prot.chansetting(cuenforcebans,30,1,$chan),%unban = 0,%tmp
  if ($banmask iswm %.myaddress) {
    if ($nick == $me) { info.a You banned yourself in $chan $^bp($banmask) }
    else { info.a $nick banned you in $chan $^bp($banmask) }
if ($_prot.chansetting(cuonmeban,33,1,$chan)) {
    if ($me isop $chan) {
      if ($_prot.chansetting(cuonmeban,33,5,$chan)) { ban -r $chan $banmask }
      if ($_not(%isprot)) {
        if ($_prot.chansetting(cuonmeban,33,2,$chan)) { deop $chan $nick }
        if ($_prot.chansetting(cuonmeban,33,3,$chan)) { kick $chan $nick }
        if ($_prot.chansetting(cuonmeban,33,4,$chan)) { ban $chan $nick }
        %tmp = $_flood.chan(cumban,14,1,%+onban.num,$nick,$fulladdress,%++maskclon,$chan,_l_)
      }
    }
    else {
      if ($_prot.chansetting(cuonmeban,33,5,$chan)) { _bot.use 0 unbanme $chan $banmask }
      if ($_not(%isprot)) {
        if ($_prot.chansetting(cuonmeban,33,3,$chan)) { _prot.doitbottie!doit! kick $chan $nick }
        elseif ($_prot.chansetting(cuonmeban,33,2,$chan)) { _prot.doitbottie!doit! deop $chan $nick }
        if ($_prot.chansetting(cuonmeban,33,4,$chan)) { _prot.doitbottie!doit! ban $chan $nick }
      }
    }
}
    return
  }
  if ($me !isop $chan) { return }

  if ($_not($_rchini(userbans,$chan))) && ($nick != $me) && (b !isincs %++flags) && (m !isincs %++flags) { %unban = 1 }
  while (%i) && ($_not(%unban)) {
    var %mask = $ialchan($banmask,$chan,%i),%nick = $gettok(%mask,1,33),%flags = $_maskflags(%mask,%chan)
    if ((f isincs %flags) || (o isincs %flags) || (m isincs %flags)) && ($nick != $me) && ($banmask !iswm $fulladdress) && (m !isincs %++flags) && (b !isincs %++flags) {
      _puthelp $nick & _qnotice $nick $_evaltext($replace($_defmsg(dontbanfriend),<BANMASK>,$banmask))
      %unban = 1
    }
    elseif (%enforce) { .timerENFORCEBAN $+  , $+ $chan $+ , $+ $banmask $+ , $+ %nick 1 5 _prot.enforceban $chan $banmask $nick %nick %mask }
    dec %i
  }
  if ($_not(%unban)) {
    if (. isin $nick) && ($_getsetup(script,bounce-bans)) && ($_not($_isban($banmask,$chan))) { %unban = 1 }
  }
  if (%unban) {
    .timerENFORCEBAN $+  , $+ $chan $+ , $+ $banmask $+ ,* off
    ban -r $chan $banmask
  }
  if (%isprot) { return }
  %tmp = $_flood.chan(cumban,14,1,%+onban.num,$nick,$fulladdress,%++maskclon,$chan,_l_)
}
ON *:UNBAN:#:{ .timerENFORCEBAN $+  , $+ $chan $+ , $+ $banmask $+ ,* off }
; /__prot.enforceban #channel banmask banner nick fulladdress
alias _prot.enforceban {
  if ($me isop $1) && ($4 ison $1) && ($_not($_isprot($5,$1,0))) { kick $1 $4 $_evaltext($replace($_defmsg(kickenforebans),<CHAN>,$1,<BANMASK>,$2,<BANNER>,$3,<NICK>,$4)) }
}
ON *:MODE:#:{
  if ($me !isop $chan) || ($_prot.isprot($chan,0)) { return }
  var %modes = $_fixmodes($1),%s
  %s = $_prot.chansetting(cudmodel,15,1-,$chan)
  if (+l isincs %modes) && ($gettok(%s,1,46)) && ($chan($chan).limit <= $gettok(%s,2,46)) { _dummy $_triggered(cudmodel,$chan,$_nospaces(¶,cudmodel,!,%++maskclon,$chan),$nick,$site,$address,$fulladdress,0,0,0,0,0) }
  %s = $_prot.chansetting(cudmodek,16,1-,$chan)
  if (+k isincs %modes) && ($gettok(%s,1,46)) { _dummy $_triggered(cudmodek,$chan,$_nospaces(¶,cudmodek,!,%++maskclon,$chan),$nick,$site,$address,$fulladdress,0,0,0,0,0) }
  %s = $_prot.chansetting(cudmodei,17,1-,$chan)
  if (+i isincs %modes) && ($gettok(%s,1,46)) { _dummy $_triggered(cudmodei,$chan,$_nospaces(¶,cudmodei,!,%++maskclon,$chan),$nick,$site,$address,$fulladdress,0,0,0,0,0) }
  if ($_prot.isprot($chan,1)) { return }
  _prot.modetopic
}
ON *:SERVERMODE:#:{

  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;; elaborate
  if ($me isop $chan) && ($_getsetup(script,bounce-modes)) { mode $chan $replace($1,-,_,+,-,_,+) $2- }
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

}
ON *:TOPIC:#:{
  if ($me !isop $chan) || ($_prot.isprot($chan,1)) { return }
  _prot.modetopic
}
alias _prot.modetopic { var %tmp = $_flood.chan(cumodetopic,22,1,0,$nick,$fulladdress,%++maskclon,$chan,_l_) }
ON *:SERVEROP:#:{
  if ($me !isop $chan) { return }
  var %wasop = 0,%triggerednethack,%tmp = $opnick $+ $chan
  if (%+netsplitwasop. [ $+ [ %tmp ] ] ) {
    .timer 1 0 unset % $+ +netsplitwasop. $+ %tmp
    %wasop = 1
  }
  if ($_prot.chansetting(cunethack,18,1,$chan)) && ($_not(%++service2)) && (o !isincs %++flags2) && (b !isincs %++flags2) && (m !isincs %++flags2) {
    if (w isincs %++flags2) || ($_rchini(wasoptest,$chan)) {
      if (%wasop) { %triggerednethack = 0 }
      else { %triggerednethack = 1 }
    }
    else { %triggerednethack = 1 }
    if (%triggerednethack) { _dummy $_triggered(cunethack,$chan,$_nospaces(¶,cunethack,!,%++maskclon2,$chan),$opnick,$gettok(%++fulladdress2,2,64),$gettok(%++fulladdress2,2,33),%++fulladdress2,0,0,0,0,0) }
  }
  _prot.onop
}
ON *:OP:#:{
  if ($me !isop $chan) { return }
  _prot.onop
}
ON *:OWNER:#:{
  if ($me !isop $chan) { return }
  _prot.onop
}
alias _prot.onop {
  var %tmp
  if ($_prot.chansetting(cubitchmode,19,1,$chan)) && ($nick != $me) && ($opnick != $me) && (m !isincs %++flags) && (b !isincs %++flags) && (b !isincs %++flags2) && (o !isincs %++flags2) && (m !isincs %++flags2) && (n !isincs %++flags2) {
    %tmp = $_triggered(cubitchmode,$chan,$_nospaces(¶,cubitchmode,!,%++maskclon2,$chan),$opnick,$gettok(%++fulladdress2,2,64),$gettok(%++fulladdress2,2,33),%++fulladdress2,0,0,0,0,0)
  }
  if ($opnick == $me) {
    if (%Øcukickrevenge. [ $+ [ $chan ] ] ) {
      var %nick = $gettok($ifmatch,1,32),%time = $gettok($ifmatch,2,32),%reason = $gettok($ifmatch,3-,32),%a = $_address(%nick,5)
      if (%nick ison $chan) { %tmp = $_triggered(cukickrevenge,$chan,$_nospaces(¶,Øcukickrevenge,!,%nick,$chan),%nick,$gettok(%a,2,64),$gettok(%a,2,33),%a,%time,%reason,0,0,0) }
    }
    if (%Øcudeoprevenge. [ $+ [ $chan ] ] ) {
      var %nick = $gettok($ifmatch,1,32),%time = $gettok($ifmatch,2,32),%a = $_address(%nick,5)
      if (%nick ison $chan) { %tmp = $_triggered(cudeoprevenge,$chan,$_nospaces(¶,Øcudeoprevenge,!,%nick,$chan),%nick,$gettok(%a,2,64),$gettok(%a,2,33),%a,%time,0,0,0,0) }
    }
    if (%Øonop_perform_op. [ $+ [ $chan ] ] != $null) { op $chan $replace($ifmatch,$chr(44),$chr(32)) }
    if (%Øonop_perform_deop. [ $+ [ $chan ] ] != $null) { deop $chan $replace($ifmatch,$chr(44),$chr(32)) }
    if (%Øonop_perform_voice. [ $+ [ $chan ] ] != $null) { voice $chan $replace($ifmatch,$chr(44),$chr(32)) }
    if (%Øonop_perform_devoice. [ $+ [ $chan ] ] != $null) { devoice $chan $replace($ifmatch,$chr(44),$chr(32)) }
    if (%Øonop_perform_kick. [ $+ [ $chan ] ] != $null) { kick $chan $replace($ifmatch,$chr(32),$chr(44)) }
    if (%Øonop_perform_ban. [ $+ [ $chan ] ] != $null) { ban $chan $replace($ifmatch,$chr(32),$chr(44)) }
    if (%Øonop_perform_unban. [ $+ [ $chan ] ] != $null) { ban -r $chan $replace($ifmatch,$chr(32),$chr(44)) }
    unset %Øcudeoprevenge. $+ $chan %Øcukickrevenge. $+ $chan %Øonop_perform_op. $+ $chan %Øonop_perform_deop. $+ $chan %Øonop_perform_voice. $+ $chan %Øonop_perform_devoice. $+ $chan %Øonop_perform_kick. $+ $chan %Øonop_perform_ban. $+ $chan %Øonop_perform_unban. $+ $chan
  }
  .timer 1 0 unset % $+ +netsplitwasop. $+ $opnick $+ $chan
}
ON *:JOIN:#:{
  var %nosplit = 1,%tmp
  if ($_usersplit($nick)) {
    .timer 1 0 _netsplit.remnick $nick
    %nosplit = 0
  }
  if ($me !isop $chan) || ($_prot.isprot($chan,1)) { return }
  if (%nosplit) { %tmp = $_prot.joinpart }
  if ($istok(%+clones.immunes,$site,32) == $false) && ($_prot.chansetting(cuclones,23,1,$chan)) {
    var %max = $_prot.chansetting(cuclones,23,2,$chan)
    if (%max > 1) && (%+clones.num >= %max) {
      var %o = $_prot.chansetting(exemptops,26,1,$chan),%v = $_prot.chansetting(exemptvoiced,27,1,$chan)
      _cclones $chan %++maskclon $iif(%o,%o,0) $iif(%v,%v,0)
    }
  }
  %tmp = $_prot.badnick($chan,$nick,$fulladdress,$_nospaces(¶,cubadnick,!,%++maskclon,$chan))
  %tmp = $_prot.badident($chan,$nick,$fulladdress,$_nospaces(¶,cubadident,!,%++maskclon,$chan))
}
ON *:PART:#:{
  if ($me !isop $chan) || ($_prot.isprot($chan,1)) { return }
  var %tmp = $_prot.joinpart
}
alias _prot.joinpart {
  var %tmp
  %tmp = $_flood.chanbotnet(cbjoinpart,4,1,0,$chan,_l_)
  %tmp = $_flood.chan(cujoinpart,20,1,0,$nick,$fulladdress,%++maskclon,$chan,_l_)
}
ON *:NICK:{
  if (%++service) || (b isincs %++flags) || ($newnick == $me) { return }
  var %fulladdress = $newnick $+ ! $+ $address,%i = $comchan($newnick,0),%chan
  while (%i) {
    var %chan = $comchan($newnick,%i),%flags = $_nickflags(%++handle,%chan)
    if ($me !isop %chan) {  }
    elseif (b isincs %flags) || (f isincs %flags) || (m isincs %flags) || (n isincs %flags) || (($_rchini(dontkickops,%chan)) && (o isincs %flags)) {  }
    elseif ($_prot.chansetting(exemptops,26,1,%chan)) && ($newnick isop %chan) {  }
    elseif ($_prot.chansetting(exemptvoiced,27,1,%chan)) && ($newnick isvo %chan) {  }
    elseif ($_flood.chanbotnet(cbnick,5,1,0,%chan,_l_)) {  }
    elseif ($_flood.chan(cunick,21,1,0,$newnick,%fulladdress,%++maskclon,%chan,_l_)) {  }
    elseif ($_prot.badnick(%chan,$newnick,%fulladdress,$_nospaces(¶,cubadnick,!,%++maskclon,%chan))) { }
    elseif ($_prot.badident(%chan,$newnick,%fulladdress,$_nospaces(¶,cubadident,!,%++maskclon,%chan))) { }
    dec %i
  }
}
;
; $_prot.badnick(chan,nick,fulladdress,varid)
alias _prot.badnick {
  if ($_prot.chansetting(cubadnick,24,1,$1)) {
    var %tmp = cubadnick_ $+ $1
    if ($hget(_aircprot,%tmp) != $null) { %c.prot.iswmatch = $ifmatch }
    else { %c.prot.iswmatch = $hget(_aircprot,cubadnick_global) }
    if (%c.prot.iswmatch != $null) {
      if ($_prot.iswmatch(cubadnick,$1,$4,$2,$gettok($3,2,64),$gettok($3,2,33),$3,44,0,$2)) {
        .timer_cubadnick $+ $1 $+ , $+ $2 1 30 _prot.tbadnick $1 $2 $3 $4
        return 1
      }
    }
    unset %c.prot.iswmatch
  }
}
alias _prot.tbadnick {
  var %chan = $1,%nick = $2,%fulladdress = $3,%flags = $_maskflags(%fulladdress,%chan)
  if ($me !isop %chan) || (f isincs %flags) || (($_rchini(dontkickops,%chan)) && (o isincs %flags)) || (m isincs %flags) || (n isincs %flags) || (($_prot.chansetting(exemptops,26,1,%chan)) && (%nick isop %chan)) || (($_prot.chansetting(exemptvoiced,27,1,%chan)) && (%nick isvo %chan)) { return }
  if (%nick !ison %chan) { return }
  return $_prot.badnick($1,$2,$3,$4)
}
;
; $_prot.badident(chan,nick,fulladdress,varid)
alias _prot.badident {
  if ($_prot.chansetting(cubadident,25,1,$1)) {
    var %tmp = cubadident_ $+ $1
    if ($hget(_aircprot,%tmp) != $null) { %c.prot.iswmatch = $ifmatch }
    else { %c.prot.iswmatch = $hget(_aircprot,cubadident_global) }
    if (%c.prot.iswmatch != $null) {
      if ($_prot.iswmatch(cubadident,$1,$4,$2,$gettok($3,2,64),$gettok($3,2,33),$3,44,0,$gettok($gettok($3,2,33),1,64))) {
        .timer_cubadnick $+ $1 $+ , $+ $2 1 30 _prot.tbadident $1 $2 $3 $4
        return 1
      }
    }
    unset %c.prot.iswmatch
  }
}
alias _prot.tbadident {
  var %chan = $1,%nick = $2,%fulladdress = $3,%flags = $_maskflags(%fulladdress,%chan)
  if ($me !isop %chan) || (f isincs %flags) || (o isincs %flags) || (m isincs %flags) || (n isincs %flags) || (($_prot.chansetting(exemptops,26,1,%chan)) && (%nick isop %chan)) || (($_prot.chansetting(exemptvoiced,27,1,%chan)) && (%nick isvo %chan)) { return }
  if (%nick !ison %chan) { return }
  return $_prot.badident($1,$2,$3,$4)
}
alias -l _prot.doitbottie!doit! {
  var %com = $1,%chan = $2,%target = $3,%reason = $4-,%bot,%var = Øonop_perform_ $+ %com $+ . $+ %chan,%tvar = % $+ %var,%tvar = [ [ %tvar ] ]
  _bot.use 0 %com %chan %target %reason
  ; shit! we must wait...
  if ($result) { set -u120 % [ $+ [ %var ] ] $addtok(%tvar,%target,44) }
}