;IRcap8 937e60aec683bc6229d154d0eb7207cf
; 1ban, 2clones, 3limclones, 4nicks, 5maxops, 6repe, 7nrepe, 8lineas, 9nlineas, 10exce, 11nexce, 12tacos, 13spam, 14spanjoin, 15caps, 16%caps, 17colores, 
;18ncolores, 19ctcp, 20DOS, 21nickf, 22modos, 23topic, 24serverop, 25mdeop, 26mban, 27mkick, 28mjoin, 29exops, 30exvoz, 31exauto, 32whois, 33saludo, 
;34despide, 35 oculta join, 36floodnet, 37spamnoti, 38autovoz , 39 limiteentradas, 40 limentradasmax

on @1:TEXT:*:#: canalprot $1-
on @1:ACTION:*:#: canalprot $1-
on @1:NOTICE:*:#: canalprot $1-

alias KPROT var %a = %cpo. [ $+ [ $1 $+ .dat ] ] | if (!%a) { var %a = %canalcfg.pro } | return $gettok(%a,$2,44)
alias KEXCL {
  if ($kprot(#,29) == 1) && ($1 != OP) { if ($nick isop #) || ($nick isowner #) return NO }
  if $kprot(#,30) == 1 { if ($nick isvoice #) return NO }
  if $kprot(#,31) == 1 { if ($ulevel == 10) return NO }
}

alias CANALPROT {
  var %cpr.pro = %cpo. [ $+ [ # $+ .dat ] ] , %cca = # $+ . $+ $cid | if  (!%cpr.pro) { var %cpr.pro = %canalcfg.pro }

  if $gettok(%cpr.pro,29,44) == 1 { if ($nick isop #) || ($nick isowner #) return }
  if $gettok(%cpr.pro,30,44) == 1 { if ($nick isvoice #) return }
  if $gettok(%cpr.pro,31,44) == 1 { if ($ulevel == 10) return }

  ;repeticiones
  if $gettok(%cpr.pro,6,44) == 1 {
    if (%cpo. [ $+ [ %cca $+ .ufrase ] ] == $nick $1-) { 
      inc %cpo. $+ %cca $+ .nrepe | .timerCPO. $+ %cca $+ .nrepe 1 10 unset %cpo. $+ %cca $+ .nrepe
      if (%cpo. [ $+ [ %cca $+ .nrepe ] ] >= $gettok(%cpr.pro,7,44)) { unset %cpo. [ $+ [ %cca $+ .nrepe ] ] | infrax REPE }
    }
    else unset %cpo. $+ %cca $+ .nrepe
    set %cpo. $+ %cca $+ .ufrase $nick $1-
  }

  ;exceso lineas
  if $gettok(%cpr.pro,8,44) == 1 {
    if (%cpo. [ $+ [ %cca $+ .ulinea ] ] == $nick) { 
      inc %cpo. $+ %cca $+ .nlinea | .timerCPO. $+ %cca $+ .nlinea 1 10 unset %cpo. $+ %cca $+ .nlinea
      if (%cpo. [ $+ [ %cca $+ .nlinea ] ] >= $gettok(%cpr.pro,9,44)) { unset %cpo. [ $+ [ %cca $+ .nlinea ] ] | infrax MAXL }
    }
    else unset %cpo. $+ %cca $+ .nlinea
    set %cpo. $+ %cca $+ .ulinea $nick
  }

  ;exceso caracteres
  if $gettok(%cpr.pro,10,44) == 1 {
    if (%cpo. [ $+ [ %cca $+ .uexce ] ] == $nick) { 
      inc %cpo. $+ %cca $+ .nexce $len($1-) | .timerCPO. $+ %cca $+ .nexce 1 10 unset %cpo. $+ %cca $+ .nexce
      if (%cpo. [ $+ [ %cca $+ .nexce ] ] >= $gettok(%cpr.pro,11,44)) { unset %cpo. [ $+ [ %cca $+ .nexce ] ] | infrax EXCE }
    }
    else unset %cpo. $+ %cca $+ .nexce
    set %cpo. $+ %cca $+ .uexce $nick
  }

  ;anti tacos
  if $gettok(%cpr.pro,12,44) == 1 { var %prh = $numtok(%pc.prta,22) | while (%prh > 0) { if ($gettok(%pc.prta,%prh,22) iswm $1-) { infrax TACO | var %prh = 0 } | dec %prh } }

  ;anti spam
  if $gettok(%cpr.pro,13,44) == 1 { var %prh = $numtok(%spam.txt,22) | while (%prh > 0) { if ($gettok(%spam.txt,%prh,22) iswm $1-) { infrax SPAM | var %prh = 0 } | dec %prh } }

  ;caps
  if $gettok(%cpr.pro,15,44) == 1 { if ($len($strip($1-)) > 10) { if ($mayus($strip($replace($1-,D,d))) > $gettok(%cpr.pro,16,44)) infrax CAPS } }

  ;colores
  if $gettok(%cpr.pro,17,44) == 1 { if $count($1-,) > $gettok(%cpr.pro,18,44) infrax COLO }
}


on @1!:JOIN:#: {
  if ($kprot(#,28) == 1)  && ($KEXCL != NO) {
    var %cca = # $+ . $+ $cid
    inc %cpo. $+ %cca $+ .join | .timerCPO. $+ %cca $+ .join 1 8 unset %cpo. $+ %cca $+ .join
    if (%cpo. [ $+ [ %cca $+ .join ] ] == 6) { if ($address($nick,2) != $address($me,2)) { infrax MJOIN } }
  }
  if ($kprot(#,2) == 1) { if ($ial($address($nick,$kprot(#,1)),0) > $kprot(#,3)) infrax CLON }
  limitajoins #
}
on @1:PART:#: limitajoins #
on 1:QUIT: var %i = $comchan($nick,0) | while (%i > 0) { if ($kprot($comchan($nick,%i),39) == 1) { limitajoins $comchan($nick,%i) } | dec %i }

alias limitajoins {
  if ($1 == set) && ($me isop $2) { mode $2 +l $calc($nick($2,0) + $kprot($2,40)) | return }
  if ($kprot($1,39) == 1) { 
    var %cca = $1 $+ . $+ $cid
    if (!$timer(LIMJOIN $+ %cca)) { .timerLIMJOIN $+ %cca 1 60 limitajoins set $1 }
  }
}

on @1!:DEOP:#: {
  if ($kprot(#,25) == 1) && ($KEXCL(OP) != NO) {
    var %cca = # $+ . $+ $cid
    set %cpo. $+ %cca $+ .deop %cpo. [ $+ [ %cca $+ .deop ] ] $site | .timerCPO. $+ %cca $+ .deop 1 6 unset %cpo. $+ %cca $+ .deop 
    if ($count(%cpo. [ $+ [ %cca $+ .deop ] ],$site) == 3) { if ($address($nick,2) != $address($me,2)) { infrax MDEOP } }
  }
}

on @1!:KICK:#: {
  if  ($kprot(#,27) == 1) && ($KEXCL(OP) != NO) {
    var %cca = # $+ . $+ $cid
    set %cpo. $+ %cca $+ .kick %cpo. [ $+ [ %cca $+ .kick ] ] $site | .timerCPO. $+ %cca $+ .kick 1 6 unset %cpo. $+ %cca $+ .kick
    if ($count(%cpo. [ $+ [ %cca $+ .kick ] ],$site) == 3) { if ($address($nick,2) != $address($me,2)) { infrax MKICK } }
  }
}
on @1:KICK:#: limitajoins #

on @1!:BAN:#: {
  if  ($kprot(#,26) == 1) && ($KEXCL(OP) != NO) {
    var %cca = # $+ . $+ $cid
    set %cpo. $+ %cca $+ .ban %cpo. [ $+ [ %cca $+ .ban ] ] $site | .timerCPO. $+ %cca $+ .ban 1 6 unset %cpo. $+ %cca $+ .ban
    if ($count(%cpo. [ $+ [ %cca $+ .ban ] ],$site) == 3) { if ($address($nick,2) != $address($me,2)) { infrax MBAN } }
  }
}

on @1!:NICK: {
  if ($KEXCL == NO) return
  var %cca = $cid
  if ($address($newnick,2) != $address($me,2)) && ($len(%cpo. [ $+ [ %cca $+ .nick ] ]) < 888) { set %cpo. $+ %cca $+ .nick %cpo. [ $+ [ %cca $+ .nick ] ] $site | .timerCPO. $+ %cca $+ .NICK 1 10 unset %cpo. $+ %cca $+ .nick }
  if ($count(%cpo. [ $+ [ %cca $+ .nick ] ],$site) == 4) { 
    var %i = $comchan($newnick,0) | while (%i > 0) { if $kprot($comchan($newnick,%i),21) == 1 { infrax FNICK $comchan($newnick,%i) $newnick } | dec %i }
  }
}

on @1!:TOPIC:#: {
  if ($kprot(#,23) == 1) && ($KEXCL != NO) { 
    infrax TOPIC 
    var %a = usr\ $+ $remove(#,$chr(35)) $+ .cch
    if ($exists(%a)) qc topic # $inichr($readini %a i topic2)
    else qc topic # $inichr($readini usr/canalglobal.ini i topic2)
  }
}
on @1!:MODE:#: if ($kprot(#,22) == 1) && ($KEXCL != NO)  { infrax MODO | var %mo = $replace($1-,-,&) | %mo = $replace(%mo,+,-) | qc mode $chan $replace(%mo,&,+) }
on @1!:SERVEROP:#: if ($kprot(#,24) == 1) && ($KEXCL != NO) { if ($me != $opnick) { infrax SERVEROP | qc mode # -o $opnick } }
on @1!:OP:#: if ($opnick(#,0) > $kprot(#,5))  && ($opnick != $me) && ($KEXCL(OP) != NO)  { qc mode # -o $opnick }

on 1:signal:FLOOD: {
  if ($left($4,1) == $chr(35)) {
    if ($me isop $4) {
      if ($kprot($4,29) == 1) { if ($2 isop $4) || ($2 isowner $4) return }
      if ($kprot($4,30) == 1) { if ($2 isvoice $4) return }
      if ($1 == ctcp) && ($kprot($4,19) == 1) { infrax CTCP $4 $2 }
      if ($1 == ctcpnet) && ($kprot($4,36) == 1) { infrax FNET $4 $2 }
      if ($1 == dos) && ($kprot($4,20) == 1) { infrax DOS $4 $2 }
      if ($1 == noti) {
        var %i = $comchan($2,0) | while (%i > 0) { var %a = $comchan($2,%i) | if ($me isop %a) && ($kprot(%a,37) == 1) infrax NOTI %a $2 | dec %i }
      }
    }
  }
}

alias INFRAX {
  if ($ulevel == 69) return
  var %ni = $nick , %ca = # | if ($2) { var %ni = $3 , %ca = $2 }
  if (%cpo.no2k == $1 %ni) return | set -u5 %cpo.no2k $1 %ni

  var %t = %ni $+ . $+ $1 , %n = $readini(usr\infrac.tmp,%ca,%t) | inc %n
  var %acc =  usr\canalglobal.ini | if (%cpo. [ $+ [ %ca $+ .dat ] ]) { var %acc = usr\ $+ $remove(%ca,$chr(35)) $+ .cch }
  %ac = $readini %acc $1 %n | if (!%ac) { dec %n | %ac = $readini %acc $1 %n }
  writeini usr\infrac.tmp %ca %t %n

  if $gettok(%ac,14,172) == 1 && ($gettok(%ac,15,172) !isin $chan(%ca).mode) {
    qc mode %ca $gettok(%ac,15,172) | if $gettok(%ac,16,172) == 1 .timerQUITAMODO $+ %ca 1 $gettok(%ac,17,172) mode %ca - $+ $gettok(%ac,15,172)
  }

  if ($gettok(%ac,1,172) == 1) && (%ni isop %ca) qc mode %ca -o %ni
  var %tiban = $gettok($gettok(%ac,3,172),1,58)
  if ($gettok(%ac,1,172) == 2) { if ($ial($address(%ni,%tiban),0) > 1) || (%ni isop %ca) qc dopa %ca %ni }
  if $gettok(%ac,2,172) == 1 {
    if $gettok(%ac,4,172) == 1 qc ban -u $+ $gettok(%ac,5,172) %ca %ni %tiban
    else qc ban %ca %ni %tiban
  }
  if $gettok(%ac,6,172) == 1 _ca ipkick $address(%ni,%tiban) %ca $remp($inichr($gettok(%ac,7,172)))
  ;-
  %cponick = %ni | %cpocanal = %ca | %cpoip = $gettok($address(%ni,2),2,64)
  if $gettok(%ac,8,172) == 1 { echo -s $remp($inichr($gettok(%ac,9,172))) | sss noti }
  if $gettok(%ac,10,172) == 1 { qc $gettok($gettok(%ac,11,172),1,32) %ni $remp($gettok($inichr($gettok(%ac,11,172)),2-99,32)) }
  if $gettok(%ac,12,172) == 1 { qc $gettok($gettok(%ac,13,172),1,32) %ca $remp($gettok($inichr($gettok(%ac,13,172)),2-99,32)) }
  ;-
  if $gettok(%ac,18,172) == 1 qc $remp($gettok(%ac,19,172))
  unset %cponick %cpocanal %cpoip
}

on 1:start: .timer 1 5 .remove usr\infrac.tmp | unset %cpo.*

alias -l MAYUS {
  var %p = $remove($1-,$chr(32)) , %letra = $len(%p) , %caps = 0
  while (%letra > 0) {
    var %ch = $mid(%p,%letra,1)
    if ($asc(%ch) isnum 65-90) { inc %caps }
    dec %letra
  }
  return $int($calc(%caps / ($len(%p)) * 100))
}

alias -l remp return $replace($1-,<nick>,%cponick,<canal>,%cpocanal,<chan>,%cpocanal,<ip>,%cpoip,<url>,$urlcap,<ver>,%ircapv,<me>,$me)

;EOF