We do not take any responsability for any user submitted content - Copyright @ Daniel Nøhr

Anti-takeover script NOT by me!

Posted by Futz0r at 30-06-2010 06:00:45

Paste

on *:load:{
  echo -a ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Anti Takeover;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  echo -a Thanks for using 1Force - The one Force to roll them all
  echo -a Version: 1.0
  echo -a Don't rip, whine when you ask for the next version
  echo -a The commands are at http://1Force.ongames.net
  echo -a ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Credits;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  echo -a I got a very good help and support from AnimateZ & xtr
  echo -a They have support me all the time so i can only say THANKS!!!!!
  set %date $date
}
on *:unload:{
  echo -a Thanks for useing 1Force Anti Takeover :)
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Made by AnimatuZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
on *:invite:#:{
  if ($nick == L) || ($nick == Q) {
    join $chan
  }
}
raw 354:*: {
  if (%lamer.who == on) {
    haltdef | writeini prot/lastlamer.ini lastlamer %last.chan $+(*!*@,$2) $3 $iif($4,$4,None) %last.lamer @ $asctime
  }
}
raw 315:*: {
  if (%lamer.who == on) {
    haltdef
  }
}
raw 471:*:{
  haltdef
  .msg %bot. [ $+ [ $2 ] ] invite $2
}
raw 473:*:{
  haltdef
  .msg %bot. [ $+ [ $2 ] ] invite $2
}
raw 474:*:{
  haltdef
  .msg %bot. [ $+ [ $2 ] ] invite $2
}
raw 475:*:{
  haltdef
  .msg %bot. [ $+ [ $2 ] ] invite $2
}
raw 477:*:{
  haltdef
  .msg %bot. [ $+ [ $2 ] ] invite $2
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Support by AnimatuZ & xtr;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
on @*:op:#:{
  inc %ops
  if (on iswm $hget($+(atake.,$network,.,$chan),guard)) {
    if ($opnick == $me) {
      var %x = 1
      while ($hget(badboy. $+ $chan,%x).item) {
        .pushmode -n $chan +b $hget(badboy. $+ $chan,%x).data
        if ($hget(badboy. $+ $chan,%x).item ison $chan) { .putkick -f $chan $hget(badboy. $+ $chan,%x).item 10[Protection by #Futz0r.dk $+ 10] Reason: 10( $+ Moron Dont Try To Get Me Off $+ 10) Kick(s): 10( $+ $kc $+ 10) }
        inc %x
      }
    }
    if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) {
      if ($deop($address($nick,1))) {
        .hdel Deop $address($nick,1)
      }
    }
    if ($nick == Q) || ($nick == L) || ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) || ($nick == $server) || ($nick == $me) {
      .return
    }
    else {
      .pushmode -n $chan -o $opnick
      .pushmode -n $chan -o $nick
      check.lamer $nick $chan $nick opped $opnick
    }
  }
}
on *:deop:#:{
  inc %deops
  if (on iswm $hget($+(atake.,$network,.,$chan),guard)) {
    if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) {
      if (!$deop($address($nick,1))) {
        .hadd -m deop $address($nick,1)
      }
    }
    if ($opnick == $me) {
      .msg $iif(Q ison $chan,Q,L) op $chan
    }
    if ($nick == Q) || ($nick == L) || ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) || ($nick == $server) || ($nick == $me) {
      .return
    }
    if ($opnick == $me) {
      writeini -n prot/blacklist.ini $chan $address($nick,2) $nick Deopped me
      .hadd -mu60 badboy. $+ $chan $nick $address($nick,2)
      check.lamer $nick $chan $nick deopped me
    }
    else {
      .pushmode -n $chan +o $opnick
      .pushmode -n $chan -o $nick
      check.lamer $nick $chan $nick deopped $opnick
    }
  }
}
on @*:voice:#:{
  inc %voices
  if (on iswm $hget($+(atake.,$network,.,$chan),guard)) {
    if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) {
      if ($devoice($address($nick,1))) {
        .hdel Devoice $address($nick,1)
      }
    }
    if ($nick == Q) || ($nick == L) || ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) || ($nick == $server) || ($nick == $me) {
      .return
    }
    else {
      if ($vnick != $me) { .pushmode -n $chan -v $vnick }
      .pushmode -n $chan -o $nick
      check.lamer $nick $chan $nick voiced $vnick
    }
  }
}
on @*:devoice:#:{
  inc %devoices
  if (on iswm $hget($+(atake.,$network,.,$chan),guard)) {
    if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) {
      if (!$devoice($address($nick,1))) {
        .hadd -m devoice $address($nick,1)
      }
    }
    if ($nick == Q) || ($nick == L) || ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) || ($nick == $server) || ($nick == $me) {
      .return
    }
    else {
      .pushmode -n $chan +v $vnick
      .pushmode -n $chan -o $nick
      check.lamer $nick $chan $nick devoiced $vnick
    }
  }
}
on *:kick:#:{
  inc %kicks
  if (on iswm $hget($+(atake.,$network,.,$chan),guard)) {
    if ($knick iswm $me) {
      .join $chan
    }
    if ($nick == Q) || ($nick == L) || ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) || ($nick == $server) || ($nick == $me) {
      .return
    }
    if ($knick == $me) {
      writeini -n prot/blacklist.ini $chan $address($nick,2) $nick Kicked me
      .putkick -f $chan $nick 10[Protection by #Futz0r.dk $+ 10] Reason: 10( $+ Moron Dont Try To Get Me Off $+ 10) Kick(s): 10( $+ $kc $+ 10)
      check.lamer $nick $chan $nick kicked me
    }
    else {
      .pushmode -n $chan +b $address($nick,2)
      .putkick -f $chan $nick 10[Protection by #Futz0r.dk $+ 10] Reason: 10( $+ You Don't Have Access To Kick Users $+ 10) Kick(s): 10( $+ $kc $+ 10)
      check.lamer $nick $chan $nick kicked $knick
    }
  }
}
on @*:ban:#:{
  inc %bans
  if (on iswm $hget($+(atake.,$network,.,$chan),guard)) {
    if ($nick == Q) || ($nick == L) || ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) || ($nick == $server) || ($nick == $me) {
      .return
    }
    if ($banmask iswm $ial($me)) {
      writeini -n prot/blacklist.ini $chan $address($nick,2) $nick Banned me
      addkick $chan $nick 10[Protection by #Futz0r.dk $+ 10] Reason: 10( $+ Moron Dont Try To Get Me Off $+ 10) Kick(s): 10( $+ $kc $+ 10)
      check.lamer $nick $chan $nick banned me
    }
    else {
      .pushmode -n $chan +b $address($nick,2)
      .pushmode -n $chan -b $banmask
      .putkick -f $chan $nick 10[Protection by #Futz0r.dk $+ 10] Reason: 10( $+ You Don't Have Access To Ban Users $+ 10) Kick(s): 10( $+ $kc $+ 10)
      check.lamer $nick $chan $nick banned $banmask
    }
  }
}
on @*:unban:#:{
  inc %unbans
  if (on iswm $hget($+(atake.,$network,.,$chan),guard)) {
    if ($nick == Q) || ($nick == L) || ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) || ($nick == $server) || ($nick == $me) {
      .return
    }
    else {
      .pushmode -n $chan +b $address($nick,2)
      .pushmode -n $chan +b $banmask
      .putkick -f $chan $nick 10[Protection by #Futz0r.dk $+ 10] Reason: 10( $+ You Don't Have Access To Unban Users $+ 10) Kick(s): 10( $+ $kc $+ 10)
      check.lamer $nick $chan $nick unbanned $banmask
    }
  }
}
on @*:mode:#:{
  if (on iswm $hget($+(atake.,$network,.,$chan),guard)) {
    if ($nick == Q) || ($nick == L) || ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) || ($nick == $server) || ($nick == $me) {
      .return
    }
    else {
      .pushmode -n $chan -o $nick
      .mode $chan $replacex($1,-,+,+,-) $iif($regex($1,^[^bkov]+l),$3-,$2-)
      check.lamer $nick $chan $nick changes mode
    }
  }
}
on @*:topic:#:{
  if (on iswm $hget($+(atake.,$network,.,$chan),guard)) {
    if ($nick == Q) || ($nick == L) || ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) {
      .hadd -m $+(atake.,$network,.,$chan) Topic $chan($chan).topic
      .hsave -o $+(atake.,$network,.,$chan) $+(prot/atake.,$network,.,$chan,.tbl)
    }
    if ($nick == Q) || ($nick == L) || ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) || ($nick == $server) || ($nick == $me) {
      .return
    }
    else {
      .pushmode -n $chan -o $nick
      check.lamer $nick $chan $nick changes topic
      .tjektopic
    }
  }
}
on *:open:?: {
  close -m $nick
}
on ^*:text:*:#:{
  inc %says
  haltdef
  if ($1 == $me) && (!%shit) {
    set -u5 %shit 1
    if (mode iswm $2) {
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) {
        .mode $chan $3-
      }
    }
    if (op iswm $2) {
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) {
        if ($3- == $nick) { .return }
        .mode $chan +oooooo $iif($3-,$3-,$nick)
      }
    }
    if (deop iswm $2) {
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) {
        if ($3- == $nick) || ($3- == $me) { .return }
        .mode $chan -oooooo $iif($3-,$3-,$nick)
      }
    }
    if (voice iswm $2) {
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) {
        .mode $chan +vvvvvv $iif($3-,$3-,$nick)
      }
    }
    if (devoice iswm $2) {
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) {
        .mode $chan -vvvvvv $iif($3-,$3-,$nick)
      }
    }
    if (kick iswm $2) {
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) && ($3 ison $chan) {
        if ($3 == $nick) || ($3 == $me) { .return }
        .kick $chan $3 10[Kicked10] Reason: 10( $+ $iif($4-,$4-,w00t?) $+ 10) Kick(s): 10( $+ $kc $+ 10)
      }
    }
    if (ban iswm $2) {
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($admin,1)))) {
        if ($3 != *!*@*) || ($3 != *) || ($3 != *@*) || ($3 != $me) {
          .ban $chan $3 $iif($4,$4,1)
        }
      }
    }
    if (unban iswm $2) {
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) {
        if ($3 == all) {
          var %x = 1
          while ($ibl(#,%x)) {
            .mode -n $chan -b $ibl(#,%x)
            inc %x
          }
        }
        else {
          .mode # -b $iif($3 isnum 1-45,$ibl(#,$3),$iif($3 != $null,$3,$ibl(#,1)))
        }
      }
    }
    if (kill iswm $2) {
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) && ($3 ison $chan) {
        if ($3 == $nick) || ($3 == $me) { .return }
        .ban $chan $3 $iif($4,$4,1)
        .kick $chan $3 10[Killed10] Reason: 10( $+ $iif($5-,$5-,w00t?) $+ 10) Kick(s): 10( $+ $kc $+ 10)
      }
    }
    if (topic iswm $2) {
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) {
        .topic $chan $3-
        .hadd -m $+(atake.,$network,.,$chan) Topic $3-
        .hsave -o $+(atake.,$network,.,$chan) $+(prot/atake.,$network,.,$chan,.tbl)
      }
    }
    if (mass iswm $2) {
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) {
        if ($3 == +o) {
          set -u10 %mass $nick
          .mass +o $chan
          .return
        }
        if ($3 == -o) {
          set -u10 %mass $nick
          .mass -o $chan
          .return
        }
        if ($3 == +v) {
          set -u10 %mass $nick
          .mass +v $chan
          .return
        }
        if ($3 == -v) {
          set -u10 %mass $nick
          .mass -v $chan
          .return
        }
      }
    }
    if (auto iswm $2) && (op iswm $3) {
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) {
        if ($4 == on) && (off iswm $hget($+(atake.,$network,.,$chan),ao)) || (!$hget($+(atake.,$network,.,$chan),ao)) {
          .hadd -m $+(atake.,$network,.,$chan) ao on
          .msg $chan 10[Auto op10] Going: 10( $+ on $+ 10)
          .hsave -o $+(atake.,$network,.,$chan) $+(prot/atake.,$network,.,$chan,.tbl)
          .return
        }
        if (on iswm $hget($+(atake.,$network,.,$chan),ao)) && ($4 == on) {
          .msg $chan 10[Auto op10] Already: 10( $+ on $+ 10)
        }
        if ($4 == off) && (on iswm $hget($+(atake.,$network,.,$chan),ao)) || (!$hget($+(atake.,$network,.,$chan),ao)) {
          .hadd -m $+(atake.,$network,.,$chan) ao off
          .msg $chan 10[Auto op10] Going: 10( $+ off $+ 10)
          .hsave -o $+(atake.,$network,.,$chan) $+(prot/atake.,$network,.,$chan,.tbl)
          .return
        }
        if (off iswm $hget($+(atake.,$network,.,$chan),ao)) && ($4 == off) {
          .msg $chan 10[Auto op10] Going: 10( $+ off $+ 10)
        }
        if ($4 == $null) {
          if (on iswm $hget($+(atake.,$network,.,$chan),ao)) { .msg $chan 10[Auto op10] Status: 10( $+ on $+ 10) }
          if (off iswm $hget($+(atake.,$network,.,$chan),ao)) { .msg $chan 10[Auto op10] Status: 10( $+ off $+ 10) }
        }
      }
    }
    if (auto iswm $2) && (voice iswm $3) {
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) {
        if ($4 == on) && (off iswm $hget($+(atake.,$network,.,$chan),av)) || (!$hget($+(atake.,$network,.,$chan),av)) {
          .hadd -m $+(atake.,$network,.,$chan) av on
          .msg $chan 10[Auto voice10] Going: 10( $+ on $+ 10)
          .hsave -o $+(atake.,$network,.,$chan) $+(prot/atake.,$network,.,$chan,.tbl)
          .return
        }
        if (on iswm $hget($+(atake.,$network,.,$chan),av)) && ($4 == on) {
          .msg $chan 10[Auto voice10] Already: 10( $+ on $+ 10)
        }
        if ($4 == off) && (on iswm $hget($+(atake.,$network,.,$chan),av)) || (!$hget($+(atake.,$network,.,$chan),av)) {
          .hadd -m $+(atake.,$network,.,$chan) av off
          .msg $chan 10[Auto voice10] Going: 10( $+ off $+ 10)
          .hsave -o $+(atake.,$network,.,$chan) $+(prot/atake.,$network,.,$chan,.tbl)
          .return
        }
        if (off iswm $hget($+(atake.,$network,.,$chan),av)) && ($4 == off) {
          .msg $chan 10[Auto voice10] Already: 10( $+ off $+ 10)
        }
        if ($4 == $null) {
          if (on iswm $hget($+(atake.,$network,.,$chan),av)) { .msg $chan 10[Auto voice10] Status: 10( $+ on $+ 10) }
          if (off iswm $hget($+(atake.,$network,.,$chan),av)) { .msg $chan 10[Auto voice10] Status: 10( $+ on $+ 10) }
        }
      }
    }
    if (guard iswm $2) {
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(trust.,$address($nick,1)))) {
        if ($3 == on) && (off iswm $hget($+(atake.,$network,.,$chan),guard)) || (!$hget($+(atake.,$network,.,$chan),guard)) {
          .hadd -m $+(atake.,$network,.,$chan) guard on
          .msg $chan 10[Guard10] Going: 10( $+ on $+ 10)
          .hsave -o $+(atake.,$network,.,$chan) $+(prot/atake.,$network,.,$chan,.tbl)
          .return
        }
        if (on iswm $hget($+(atake.,$network,.,$chan),guard)) && ($3 == on) {
          .msg $chan 10[Guard10] Already: 10( $+ on $+ 10)
        }
        if ($3 == off) && (on iswm $hget($+(atake.,$network,.,$chan),guard)) || (!$hget($+(atake.,$network,.,$chan),Guard)) {
          .hadd -m $+(atake.,$network,.,$chan) guard off
          .msg $chan 10[Guard10] Going: 10( $+ off $+ 10)
          .hsave -o $+(atake.,$network,.,$chan) $+(prot/atake.,$network,.,$chan,.tbl)
          .return
        }
        if (off iswm $hget($+(atake.,$network,.,$chan),guard)) && ($3 == off) {
          .msg $chan 10[Guard10] Already: 10( $+ off $+ 10)
        }
        if ($3 == $null) {
          if (on iswm $hget($+(atake.,$network,.,$chan),guard)) { .msg $chan 10[Guard10] Status: 10( $+ on $+ 10) }
          if (off iswm $hget($+(atake.,$network,.,$chan),guard)) { .msg $chan 10[Guard10] Status: 10( $+ off $+ 10) }
        }
      }
    }
    if (flyby iswm $2) {
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(trust.,$address($nick,1)))) {
        if ($3 == on) && (off iswm $hget($+(atake.,$network,.,$chan),flyby)) || (!$hget($+(atake.,$network,.,$chan),flyby)) {
          .hadd -m $+(atake.,$network,.,$chan) flyby on
          .msg $chan 10[Flyby10] Going: 10( $+ on $+ 10)
          .hsave -o $+(atake.,$network,.,$chan) $+(prot/atake.,$network,.,$chan,.tbl)
          .return
        }
        if (on iswm $hget($+(atake.,$network,.,$chan),flyby)) && ($3 == on) {
          .msg $chan 10[Flyby10] Already: 10( $+ on $+ 10)
        }
        if ($3 == off) && (on iswm $hget($+(atake.,$network,.,$chan),flyby)) || (!$hget($+(atake.,$network,.,$chan),flyby)) {
          .hadd -m $+(atake.,$network,.,$chan) flyby off
          .msg $chan 10[Flyby10] Going: 10( $+ off $+ 10)
          .hsave -o $+(atake.,$network,.,$chan) $+(prot/atake.,$network,.,$chan,.tbl)
          .return
        }
        if (off iswm $hget($+(atake.,$network,.,$chan),flyby)) && ($3 == off) {
          .msg $chan 10[Flyby10] Already: 10( $+ off $+ 10)
        }
        if ($3 == $null) {
          if (on iswm $hget($+(atake.,$network,.,$chan),flyby)) { .msg $chan 10[Flyby10] Status: 10( $+ on $+ 10) }
          if (off iswm $hget($+(atake.,$network,.,$chan),flyby)) { .msg $chan 10[Flyby10] Status: 10( $+ off $+ 10) }
        }
      }
    }
    if (clone iswm $2) {
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) {
        if ($3 == on) && (off iswm $hget($+(atake.,$network,.,$chan),clone)) || (!$hget($+(atake.,$network,.,$chan),clone)) {
          .hadd -m $+(atake.,$network,.,$chan) Clone on
          .msg $chan 10[Clone10] Going: 10( $+ on $+ 10)
          .hsave -o $+(atake.,$network,.,$chan) $+(prot/atake.,$network,.,$chan,.tbl)
          .return
        }
        if (on iswm $hget($+(atake.,$network,.,$chan),clone)) && ($3 == on) {
          .msg $chan 10[Clone10] Already: 10( $+ on $+ 10)
        }
        if ($3 == off) && (on iswm $hget($+(atake.,$network,.,$chan),clone)) || (!$hget($+(atake.,$network,.,$chan),clone)) {
          .hadd -m $+(atake.,$network,.,$chan) clone off
          .msg $chan 10[Clone10] Going: 10( $+ off $+ 10)
          .hsave -o $+(atake.,$network,.,$chan) $+(prot/atake.,$network,.,$chan,.tbl)
          .return
        }
        if (off iswm $hget($+(atake.,$network,.,$chan),clone)) && ($3 == off) {
          .msg $chan 10[Clone10] Already: 10( $+ off $+ 10)
        }
        if ($3 == $null) {
          if (on iswm $hget($+(atake.,$network,.,$chan),clone)) { .msg $chan 10[Clone10] Status: 10( $+ on $+ 10) }
          if (off iswm $hget($+(atake.,$network,.,$chan),clone)) { .msg $chan 10[Clone10] Status: 10( $+ off $+ 10) }
        }
      }
    }
    if (auto iswm $2) && (limit iswm $3) {
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) {
        if ($4 == on) && (off iswm $hget($+(atake.,$network,.,$chan),limit)) || (!$hget($+(atake.,$network,.,$chan),limit)) {
          .hadd -m $+(atake.,$network,.,$chan) limit on
          .msg $chan 10[Limit10] Going: 10( $+ on $+ 10)
          .pushmode -n $chan +l $calc($nick(#,0) + 5)
          .hsave -o $+(atake.,$network,.,$chan) $+(prot/atake.,$network,.,$chan,.tbl)
          .return
        }
        if (on iswm $hget($+(atake.,$network,.,$chan),limit)) && ($4 == on) {
          .msg $chan 10[Limit10] Already: 10( $+ on $+ 10)
        }
        if ($4 == off) && (on iswm $hget($+(atake.,$network,.,$chan),limit)) || (!$hget($+(atake.,$network,.,$chan),limit)) {
          .hadd -m $+(atake.,$network,.,$chan) limit off
          .msg $chan 10[Limit10] Going: 10( $+ off $+ 10)
          .pushmode -n $chan -l $chan($chan).limit
          .hsave -o $+(atake.,$network,.,$chan) $+(prot/atake.,$network,.,$chan,.tbl)
          .return
        }
        if (off iswm $hget($+(atake.,$network,.,$chan),limit)) && ($4 == off) {
          .msg $chan 10[Limit10] Already: 10( $+ off $+ 10)
        }
        if ($4 == $null) {
          if (on iswm $hget($+(atake.,$network,.,$chan),limit)) { .msg $chan 10[Limit10] Status: 10( $+ on $+ 10) }
          if (off iswm $hget($+(atake.,$network,.,$chan),limit)) { .msg $chan 10[Limit10] Status: 10( $+ off $+ 10) }
        }
      }
    }
    if (flood iswm $2) {
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) {
        if ($3 == on) && (off iswm $hget($+(atake.,$network,.,$chan),flood)) || (!$hget($+(atake.,$network,.,$chan),flood)) {
          .hadd -m $+(atake.,$network,.,$chan) flood on
          .msg $chan 10[Flood10] Going: 10( $+ on $+ 10)
          .hsave -o $+(atake.,$network,.,$chan) $+(prot/atake.,$network,.,$chan,.tbl)
          .return
        }
        if (on iswm $hget($+(atake.,$network,.,$chan),flood)) && ($3 == on) {
          .msg $chan 10[Flood10] Already: 10( $+ on $+ 10)
        }
        if ($3 == off) && (on iswm $hget($+(atake.,$network,.,$chan),flood)) || (!$hget($+(atake.,$network,.,$chan),flood)) {
          .hadd -m $+(atake.,$network,.,$chan) flood off
          .msg $chan 10[Flood10] Going: 10( $+ off $+ 10)
          .hsave -o $+(atake.,$network,.,$chan) $+(prot/atake.,$network,.,$chan,.tbl)
          .return
        }
        if (off iswm $hget($+(atake.,$network,.,$chan),flood)) && ($3 == off) {
          .msg $chan 10[Flood10] Already: 10( $+ off $+ 10)
        }
        if ($3 == $null) {
          if (on iswm $hget($+(atake.,$network,.,$chan),flood)) { .msg $chan 10[Flood10] Status: 10( $+ on $+ 10) }
          if (off iswm $hget($+(atake.,$network,.,$chan),flood)) { .msg $chan 10[Flood10] Status: 10( $+ off $+ 10) }
        }
      }
    }
    if (setflood iswm $2) {
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) {
        hadd -m $+(atake.,$network,.,$chan) setflood $3
        .msg $chan 10[Flood Settings10] Sets to: 10( $+ Lines: $right($3,1) $+ /Sec: $left($3,1) $+ 10)
      }
    }
    if (add iswm $2) {
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) {
        if ($3 ison $chan) && ($4 == trust) && ($address($3,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($3,1)))) {
          .hadd $+(atake.,$network,.,$chan) $+(trust.,$address($3,1)) $address($3,1)
          .msg $chan 10[Trusted Addet10] Nick: 10( $+ $3 $+ 10) Host: 10( $+ $address($3,1) $+ 10)
          .pushmode -n $chan +o $3
          .hsave -o $+(atake.,$network,.,$chan) $+(prot/atake.,$network,.,$chan,.tbl)
          .return
        }
      }
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(trust.,$address($nick,1)))) {
        if ($3 ison $chan) && ($4 == admin) {
          .hadd $+(atake.,$network,.,$chan) $+(admin.,$address($3,1)) $address($3,1)
          .msg $chan 10[Admin Addet10] Nick: 10( $+ $3 $+ 10) Host: 10( $+ $address($3,1) $+ 10)
          .hsave -o $+(atake.,$network,.,$chan) $+(prot/atake.,$network,.,$chan,.tbl)
          if ($3 !isop $chan) { .pushmode -n $chan +o $3 }
          .return
        }
      }
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) {
        if ($3 ison $chan) && ($4 == op) {
          .hadd $+(atake.,$network,.,$chan) $+(op.,$address($3,1)) $address($3,1)
          .msg $chan 10[Operator Addet10] Nick: 10( $+ $3 $+ 10) Host: 10( $+ $address($3,1) $+ 10)
          .hsave -o $+(atake.,$network,.,$chan) $+(prot/atake.,$network,.,$chan,.tbl)
          if ($3 !isop $chan) { .pushmode -n $chan +o $3 }
          .return
        }
      }
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) {
        if ($3 ison $chan) && ($4 == voice) {
          .hadd $+(atake.,$network,.,$chan) $+(voice.,$address($3,1)) $address($3,1)
          .msg $chan 10[Voice Addet10] Nick: 10( $+ $3 $+ 10) Host: 10( $+ $address($3,1) $+ 10)
          .hsave -o $+(atake.,$network,.,$chan) $+(prot/atake.,$network,.,$chan,.tbl)
          if ($3 !isvoice $chan) { .pushmode -n $chan +v $3 }
          .return
        }
      }
    }
    if (del iswm $2) {
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) {
        if ($3 ison $chan) && ($4 == trust) {
          .hdel -s $+(atake.,$network,.,$chan) $+(trust.,$address($3,1)) $address($3,1)
          .msg $chan 10[Trusted Deleted10] Nick: 10( $+ $3 $+ 10) Host: 10( $+ $address($3,1) $+ 10)
          .hsave -o $+(atake.,$network,.,$chan) $+(prot/atake.,$network,.,$chan,.tbl)
          .return
        }
      }
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(trust.,$address($nick,1)))) {
        if ($3 ison $chan) && ($4 == admin) {
          .hdel -s $+(atake.,$network,.,$chan) $+(admin.,$address($3,1)) $address($3,1)
          .msg $chan 10[Admin Deleted10] Nick: 10( $+ $3 $+ 10) Host: 10( $+ $address($3,1) $+ 10)
          .hsave -o $+(atake.,$network,.,$chan) $+(prot/atake.,$network,.,$chan,.tbl)
          if ($3 isop $chan) { .pushmode -n $chan -o $3 }
          .return
        }
      }
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) {
        if ($3 ison $chan) && ($4 == op) {
          .hdel -s $+(atake.,$network,.,$chan) $+(op.,$address($3,1)) $address($3,1)
          .msg $chan 10[Operator Deleted10] Nick: 10( $+ $3 $+ 10) Host: 10( $+ $address($3,1) $+ 10)
          .hsave -o $+(atake.,$network,.,$chan) $+(prot/atake.,$network,.,$chan,.tbl)
          if ($3 isop $chan) { .pushmode -n $chan -o $3 }
          .return
        }
      }
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) {
        if ($3 ison $chan) && ($4 == voice) {
          .hdel -s $+(atake.,$network,.,$chan) $+(voice.,$address($3,1)) $address($3,1)
          .msg $chan 10[Voice Deleted10] Nick: 10( $+ $3 $+ 10) Host: 10( $+ $address($3,1) $+ 10)
          .hsave -o $+(atake.,$network,.,$chan) $+(prot/atake.,$network,.,$chan,.tbl)
          if ($3 isvoice $chan) { .pushmode -n $chan -v $3 }
          .return
        }
      }
    }
    if (black.nick iswm $2) {
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) {
        if (!$readini(prot/blacklist.ini,$chan,$address($3,2))) && ($address($3,1) !isin $hget($+(atake.,$network),owner)) && ($3 != $me) && ($3 ison $chan) {
          writeini -n prot/blacklist.ini $chan $address($3,2) $3 $iif($4-,$4-,No Reason)
          .pushmode -n $chan +b $address($3,2)
          .putkick -f $chan $3 10[Blacklisted10] Reason: 10( $+ $iif($4-,$4-,No Reason) $+ 10) Kick(s): 10( $+ $kc $+ 10)
        }
      }
    }
    if (black.host iswm $2) {
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) {
        if (!$readini(prot/blacklist.ini,$chan,$3)) && ($3 !isin $hget($+(atake.,$network),owner)) && ($3 != $ial($me)) {
          writeini -n prot/blacklist.ini $chan $3 $4 $iif($5-,$5-,No Reason)
          .pushmode -n $chan +b $3
          .msg $chan 10[Blacklisted10] Host: 10( $+ $3 $+ 10) Nick: 10( $+ $4 $+ 10) Reason: 10( $+ $iif($5-,$5-,No Reason) $+ 10) Kick(s): 10( $+ $kc $+ 10)
        }
      }
    }
    if (unblack iswm $2) {
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) {
        var %x = 1,%b = $ini(prot/blacklist.ini,$chan,0)
        while (%x <= %b) {
          var %a = $ini(prot/blacklist.ini,$chan,%x),%n = $readini(prot/blacklist.ini,$chan,$ini(prot/blacklist.ini,$chan,%x)) if ($gettok(%n,1,32) == $3) {
            remini prot/blacklist.ini $chan %a
            .msg $chan 10[Remove10] Nick: 10( $+ $gettok(%n,1,32) $+ 10) is removed from Blacklist. Host: 10( $+ %a $+ 10) Reason: 10( $+ $gettok(%n,2-,32) $+ 10)
          }
          inc %x
        }
      }
    }
    if (ial-update iswm $2) {
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) {
        if ($timer($+($cid,.ial-update.update))) {
          .msg $chan 10[IAL-Update10] Already: 10(Started10)
        }
        if (!$timer($+($cid,.ial-update.update))) {
          .!timer $+ $cid $+ .ial-update.update 1 $$delay.who ial-update.update
          .msg $chan 10[IAL-Update10] Going to: 10(Starting10)
        }
      }
    }
    if (ibl-update iswm $2) {
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) {
        if ($timer($+($cid,.ibl-update.update))) {
          .msg $chan 10[IBL-Update10] Already: 10(Started10)
        }
        if (!$timer($+($cid,.ibl-update.update))) {
          .timer $+ $cid $+ .ibl-update.update 1 $$ibl-update.conf.delay ibl-update.update
          .msg $chan 10[IBL-Update10] Going to: 10(Starting10)
        }
      }
    }
    if (blacklist iswm $2) {
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) {
        var %u = $ini(prot/blacklist.ini,$chan,0),%i = 1
        while (%i <= %u) {
          var %y = $ini(prot/blacklist.ini,$chan,%i)
          .timer $+ %i 1 2 .notice $nick 10[Blacklisted10] Host: 10( $+ %y $+ 10) Nick: 10( $+ $gettok($readini(prot/blacklist.ini,$chan,%y),1,32) $+ 10) Reason: 10( $+ $gettok($readini(prot/blacklist.ini,$chan,%y),2-,32) $+ 10)
          inc %i
        }
      }
    }
    if (vhost iswm $2) {
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) {
        if ($read(prot/vhost.txt,w,*!*@ $+ $3)) { .msg $chan 10[Stats10] Vhost Already added }
        if (!$read(prot/vhost.txt,w,*!*@ $+ $3)) { write prot/vhost.txt *!*@ $+ $3 | .msg $chan 10[Stats10] Vhost: 10( $+ *!*@ $+ $3 $+ 10) added }
      }
    }
    if (stats iswm $2) {
      .msg $chan 10[Stats10] Since: 10( $+ %date $+ 10) Op(s): 10( $+ %ops $+ 10) Deop(s): 10( $+ %deops $+ 10) Voice(s): 10( $+ %voices $+ 10) Devoice(s): 10( $+ %devoices $+ 10) Kick(s): 10( $+ %kicks $+ 10) Ban(s): 10( $+ %bans $+ 10) Unban(s): 10( $+ %unbans $+ 10) Join(s): 10( $+ %joins $+ 10) Part(s): 10( $+ %parts $+ 10) Quit(s): 10( $+ %quits $+ 10) Message(s): 10( $+ %says $+ 10)
    }
    if (last iswm $2) && (lamer iswm $3) {
      .msg $chan 10[Last Lamer10] Nick: 10( $+ $gettok($readini(prot/lastlamer.ini,lastlamer,$chan),2,32) $+ 10) Auth: 10( $+ $gettok($readini(prot/lastlamer.ini,lastlamer,$chan),3,32) $+ 10) Address: 10( $+ $gettok($readini(prot/lastlamer.ini,lastlamer,$chan),1,32) $+ 10) Reason: 10( $+ $gettok($readini(prot/lastlamer.ini,lastlamer,$chan),4-,32) $+ 10)
    }
    if (status iswm $2) {
      if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) {
        .notice $nick 10[Status10] $nick you are 10(owner10)
        .return
      }
      if ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(trust.,$address($nick,1)))) {
        .notice $nick 10[Status10] $nick you are 10(trusted10)
        .return
      }
      if ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) {
        .notice $nick 10[Status10] $nick you are 10(admin10)
        .return
      }
      if ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(op.,$address($nick,1)))) {
        .notice $nick 10[Status10] $nick you are 10(operator10)'
        .return
      }
      if ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(voice.,$address($nick,1)))) {
        .notice $nick 10[Status10] $nick you are 10(voice10)
        .return
      }
      elseif ($address($nick,1) !isin $hget($+(atake.,$network,.,$chan),$+(voice.,$address($nick,1)))) || ($address($nick,1) !isin $hget($+(atake.,$network,.,$chan),$+(op.,$address($nick,1)))) || ($address($nick,1) !isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) || ($address($nick,1) !isin $hget($+(atake.,$network,.,$chan),$+(trust.,$address($nick,1)))) || ($address($nick,1) !isin $hget($+(atake.,$network,.,$chan),$+(owner.,$address($nick,1)))) {
        .notice $nick 10[Status10] $nick you are just a 10(user10)
        .return
      }
    }
  }
  if (on iswm $hget($+(atake.,$network,.,$chan),flood)) {
    if ($nick == $me) || ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) { .return }
    hinc $+(-mu,$right($hget($+(atake.,$network,.,$chan),setflood),1)) temp $+($chan,.,$nick))
    if ($hget(temp,$+($chan,.,$nick)) >= $left($hget($+(atake.,$network,.,$chan),setflood),1)) {
      .putkick -f $chan $nick 10[Flood10] Please stop flood 10( $+ Lines: $right($hget($+(atake.,$network,.,$chan),setflood),1) $+ /Sec: $left($hget($+(atake.,$network,.,$chan),setflood),1) $+ 10)
    }
  }
}
on ^*:action:*:#:{
  inc %says
  haltdef
  if (on iswm $hget($+(atake.,$network,.,$chan),flood)) {
    if ($nick == $me) || ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) { .return }
    hinc $+(-mu,$right($hget($+(atake.,$network,.,$chan),setflood),1)) temp $+($chan,.,$nick))
    if ($hget(temp,$+($chan,.,$nick)) >= $left($hget($+(atake.,$network,.,$chan),setflood),1)) {
      .putkick -f $chan $nick 10[Flood10] Please stop flood 10( $+ Lines: $right($hget($+(atake.,$network,.,$chan),setflood),1) Sec: $left($hget($+(atake.,$network,.,$chan),setflood),1) $+ 10)
    }
  }
}
on ^*:text:*:?:{
  haltdef
  if ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) {
    if (join iswm $1) { .join $2 }
    if (part iswm $1) && ($2 ischan) {
      .part $2
      remove $+(prot/atake.,$network,.,$2,.tbl)
      hfree $+(atake.,$network,.,$2)
    }
  }
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Support by AnimatuZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
on ^*:join:#:{
  haltdef
  inc %joins
  if (on iswm $hget($+(atake.,$network,.,$chan),clone)) && ($ialchan($wildsite,$chan,0) >= 2) && ($nick != $me) && ($chan != &partyline) {
    if ($read(prot/vhost.txt,w,$wildsite)) { .return }
    .pushmode -n $chan +b $wildsite
    var %i = 1
    while (%i <= $ialchan($wildsite,$chan,%i).nick) {
      if ($ialchan($wildsite,$chan,%i).nick ison $chan) { .putkick -f $chan $ialchan($wildsite,$chan,%i).nick 10[Protection by #Futz0r.dk $+ 10] Reason: 10( $+ $ialchan($wildsite,$chan,0) clones from $site $+ 10) Kick(s): 10( $+ $kc $+ 10) }
      inc %i
    }
  }
  if ($nick == $me) && ($chan != &partyline) {
    .bot #
    if (!$hget($+(atake.,$network,.,$chan))) { hmake $+(atake.,$network,.,$chan) 9999 }
    if ($isfile($+(prot/atake.,$network,.,$chan,.tbl))) { hload $+(atake.,$network,.,$chan) $+(prot/atake.,$network,.,$chan,.tbl) }
    .timer $+ $chan 1 60 bot $chan
    if (!$timer($+($cid,.ial-update.update))) {
      .!timer $+ $cid $+ .ial-update.update 1 $$delay.who ial-update.update
    }
    if (!$timer($+($cid,.ibl-update.update))) {
      .timer $+ $cid $+ .ibl-update.update 1 $$ibl-update.conf.delay ibl-update.update
    }
  }
  if (!$netsplit($address($nick,1))) && ((%acxmassjoin) && ($left($nick,3) == %acxmassjoin)) {
    set -u5 %acxmassjoin $left($nick,3)
    if ($me isop $chan) {
      .pushmode -n $chan +b-v *!*@ $+ $gettok($address($nick,0),2,64) $nick
      .putkick -f $chan $nick 10[Protection10] Reason: 10( $+ You Are Maybe A Proxy Bot Right? $+ 10) Kick(s): 10( $+ $kc $+ 10)
      .return
    }
  }
  elseif (!$netsplit($address($nick,1))) && (($regex($address($nick,0),^.*!~[a-z]{1}[0-9]{3}\@.*$)) || ($regex($address($nick,0),^.*!~[a-z]{1}[0-9]{4}\@.*$))) {
    set -u5 %acxmassjoin $left($nick,3)
    if ($me isop $chan) {
      .pushmode -n $chan +b-v *!*@ $+ $gettok($address($nick,0),2,64) $nick
      .putkick -f $chan $nick 10[Protection10] Reason: 10( $+ You Are Maybe A Proxy Bot Right? $+ 10)1 Kick(s): 10(1 $+ $kc $+ 10)
      .return
    }
  }
  if ($nick != $me) && (!$netsplit($address($nick,1))) && ($chan != &partyline) && (on iswm $hget($+(atake.,$network,.,$chan),flyby)) {
    set -u20 %flyby. [ $+ [ $nick ] ] 1
  }
  if ($me isop $chan) && (!$netsplit($address($nick,1))) && ($readini(prot/blacklist.ini,$chan,$wildsite)) {
    .pushmode -n $chan +b $wildsite
    .putkick -f $chan $nick 10[Blacklisted $+ 10] Reason: 10( $+ $gettok($readini(prot/blacklist.ini,$chan,$wildsite),2-,32) $+ 10) Kick(s): 10( $+ $kc $+ 10)
  }
  if ($me isop $chan) && (!$netsplit($address($nick,1))) && ($readini(prot/blacklist.ini,blacklist,$wildsite)) {
    .pushmode -n $chan +b $wildsite
    .putkick -f $chan $nick 10[Blacklisted $+ 10] Reason: 10( $+ $gettok($readini(prot/blacklist.ini,blacklist,$wildsite),2-,32) $+ 10) Kick(s): 10( $+ $kc $+ 10)
  }
  if ($me isop $chan) && (!$netsplit($address($nick,1))) && (!$devoice($address($nick,1))) && (!$readini(prot/blacklist.ini,blacklist,$wildsite)) && (on iswm $hget($+(atake.,$network,.,$chan),av)) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(voice.,$address($nick,1)))) {
    .pushmode -n $chan +v $nick
  }
  if ($me isop $chan) && (!$netsplit($address($nick,1))) && (!$deop($address($nick,1))) && (!$readini(prot/blacklist.ini,blacklist,$wildsite)) && (on iswm $hget($+(atake.,$network,.,$chan),ao)) || ($address($nick,1) isin $hget($+(atake.,$network),$+(owner.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(admin.,$address($nick,1)))) || ($address($nick,1) isin $hget($+(atake.,$network,.,$chan),$+(op.,$address($nick,1)))) {
    .pushmode -n $chan +o $nick
  }
}
on *:part:#:{
  haltdef
  inc %parts
  if (%flyby. [ $+ [ $nick ] ]) && (on iswm $hget($+(atake.,$network,.,$chan),flyby)) {
    .pushmode -n $chan +b $address($nick,1)
    .timer 1 300 pushmode -n $chan -b $address($nick,1)
  }
}
on *:quit:{
  haltdef
  inc %quits
}
on *:connect:{
  if (!$hget($+(atake.,$network))) { hmake $+(atake.,$network) 9999 }
  if ($isfile($+(prot/atake.,$network,.,tbl))) { hload $+(atake.,$network) $+(prot/atake.,$network,.tbl) }
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;Alias;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
alias tjektopic { if ($hget($+(atake.,$network,.,$chan),topic) != $chan($chan).topic) { .topic $chan $hget($+(atake.,$network,.,$chan),topic) } }
alias kc { hinc $+(atake.,$network) kicked | hsave -o $+(atake.,$network) $+(prot/atake.,$network,.tbl) kicked | return $hget($+(atake.,$network),kicked) }
alias owner { hadd -m $+(atake.,$network) $+(owner.,$1) $1 | hsave -o $+(atake.,$network) $+(prot/atake.,$network,.tbl) }
alias Devoice { if ($hget(Devoice,$1).item) { return $true } }
alias Deop { if ($hget(deop,$1).item) { return $true } }
alias bot {
  if (L ison $chan) {
    set %bot. [ $+ [ $1 ] ] L
  }
  if (Q ison $chan) {
    set %bot. [ $+ [ $1 ] ] Q
  }
}
alias check.lamer { set -u60 %lamer.who on | set -u60 %last.chan $2 | set -u60 %last.lamer $3- | who $1 n%nah }
alias mass {
  set %massppl 1
  :loop
  if ($nick($2,%massppl) == $me) || ($nick($2,%massppl) == Q) || ($nick($2,%massppl) == L) || ($nick($2,%massppl) == %mass) { inc %massppl | goto loop | halt }
  else { .pushmode -n $2 $1 $nick($2,%massppl) }
  inc %massppl
  if ($nick($2,%massppl) == $null) { unset %massppl }
  else { goto loop }
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PUTKICK ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;info:
; by wiebe @ QuakeNet
;
; version 1.0 (written and tested on mIRC 6.14)
; last edit: Sun Mar 14 2004
;
;
;What does this script do?
;
; sends kicks through a queue
;
;
;How to use this script?
;
; putkick [-fc] <channel> <nick | nick!user@host> [kick message]
;
; the -c switch can be used to clear the queue
; putkick -c clears the queue for all channels
; putkick -c #channel clears the queue for #channel
;
; the -f switch is optional, it means the kick will be send
; even if nick is not on the channel, usefull when dealing with hidden users
; when channelmode D/d is set (QuakeNet)
; putkick -f #channel nick <reason..>
;
; the script makes use of the ialmark feature, meaning that targets can change nick
; but the script will still find and kick them
; only works when the ial is on and the user is in the ial
; the script does only add/remove its sign from the ialmark, it wont delete other parts in it
; other scripts that change the ialmark may break it however
;
; script works with op and halfop, where halfop can only kick voices, regulars and hidden users
;
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS PUTKICK.START ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; set here the maximum delay (seconds) putkick should have the first time it is called
alias -l putkick.start {
  return 1
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS PUTKICK.RESTART ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; set here the delay (seconds) putkick should have between multiple kicks
alias -l putkick.restart {
  return 2
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS PUTKICK.ECHO ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; set this to 1 if you want that putkick echos what kicks are being send out
alias -l putkick.echo {
  return 1
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS PUTKICK.ECHO ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; set here the default kick message, this will be used if no kick message is specified
alias -l putkick.msg {
  return moo
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS PUTKICK ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; [-fc], $1 = channel, $2 = nick, $3- = reason
alias putkick {

  if ($1 == -f) && ($3) {
    tokenize 32 $2 $+($1,$3) $4-
  }

  elseif ($1 == -c) {
    if ($2) {
      $putkick.queue($+($cid,.putkick.*)).clear
    }
    else {
      $putkick.queue($+($cid,.putkick.,$hash($lower($1),32))).clear
    }

    return
  }

  ; place '$2-' the target and the kick message in the queue for '$1'
  putkick.queue $+($cid,.putkick.,$hash($lower($1),32)) $lower($1) $2-

  ; check if the timer does not already run
  if (!$timer($+($cid,.putkick.,$hash($lower($1),32)))) {

    ; start a timer
    .timer $+ $cid $+ .putkick. $+ $hash($lower($1),32) 1 $putkick.start putkick.dump $1
  }

  ; alias is called as an identifier ($alias)
  if ($isid) {

    ; return 'done'
    return done
  }
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS PUTKICK.DUMP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; $1 = chan
alias -l putkick.dump {

  :start

  ; set a var with the next item in queue for '$1'
  var %item = $putkick.queue($+($cid,.putkick.,$hash($lower($1),32))).next

  ; set a var to target
  var %target = $gettok(%item,2,32)
  var %number = $gettok(%item,1,32)
  var %reason = $gettok(%item,3-,32)

  while (*!*@* !iswm %target) && (%target !ison $1) && ($left(%target,2) != -f) {
    ; set a var with the next item in queue for '$1'
    var %item = $putkick.queue($+($cid,.putkick.,$hash($lower($1),32))).next

    if (%item == $null) {
      return
    }

    ; set a var to target
    var %target = $gettok(%item,2,32)
    var %number = $gettok(%item,1,32)
    var %reason = $gettok(%item,3-,32)
  }

  if (*!*@* iswm %target) {
    var %x = $ialchan($mask(%target,0),$1,0)
    while (%x) {
      if ($gettok($wildtok($ial($ialchan($mask(%target,0),$1,%x).nick).mark,$+( putkick-,$hash($lower($1),32),-*),1,32),3,45) == %number) {
        var %target = $ialchan($mask(%target,0),$1,%x).nick
        .ialmark %target $remove($ial(%target).mark,$wildtok($ial($ialchan($mask(%target,0),$1, %x).nick).mark,$+(putkick-,$hash($lower($1),32),-*),1,32))
        break
      }
      dec %x
    }
    if (%x == 0) {
      var %x = $ial($mask(%target,0),0)
      while (%x) {
        if ($gettok($wildtok($ial($ial($mask(%target,0),%x).nick).mark,$+(putkick -,$hash($lower($1),32),-*),1,32),3,45) == %number) {
          var %target = $ial($mask(%target,0),%x).nick
          .ialmark %target $remove($ial(%target).mark,$wildtok($ial($ial($mask(%target,0),%x).nic k).mark,$+(putkick-,$hash($lower($1),32),-*),1,32))
        }
        dec %x
      }
      goto start
    }
  }
  elseif ($left(%target,2) == -f) {
    var %target = $right(%target,-2)
  }

  ; op checks
  if ($me isop $1) || (($me ishop $1) && ((%target isvoice $1) || (%target isreg $1))) {


    ; check for echo setting
    if ($putkick.echo == 1) {

      ; echo what to kick
      echo -t $1 putkick kicking: %target %reason
    }

    if (%reason == $null) {
      var %reason = $putkick.msg
    }

    .quote KICK $1 %target $+(:,%reason)
  }

  ; still items in queue?
  if ($putkick.queue($+($cid,.putkick.,$hash($lower($1),32))).size > 0) {

    ; start timer for next round
    .timer $+ $cid $+ .putkick. $+ $hash($lower($1),32) 1 $putkick.restart putkick.dump $1
  }
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS PUTKICK.QUEUE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; $1 = table, $2 = chan, $3 = nick, $4- = reason
alias -l putkick.queue {

  ; we got a 2nd parameter
  if ($prop == $null) && ($2 != $null) {

    ;if ($hfind($1,$replace($2,\,\\,|,\|,$chr(40),$+(\,$chr(40)),$chr(41),$+(\ ,$chr(41)),$chr(91),$+(\,$chr(91)),$chr(93),$+(\,$chr(93)),^,\^,$chr(1 23),$+(\,$chr(123)),$chr(125),$+(\,$chr(125)),.,\.,$,\$,+,\+,*,\*,?,\? ) $+ (\s.*)?, 0,r).data == 0) && ($hfind($1,-f $+ $replace($2,\,\\,|,\|,$chr(40),$+(\,$chr(40)),$chr(41),$+(\,$chr(41)), $chr(91),$+(\,$chr(91)),$chr(93),$+(\,$chr(93)),^,\^,$chr(123),$+(\,$c hr(123)),$chr(125),$+(\,$chr(125)),.,\.,$,\$,+,\+,*,\*,?,\?) *, 0,r).data == 0) {
    if ($hfind($1,& $3 *,0,w).data == 0) && ($hfind($1,& $3,0,w).data == 0) && ($hfind($1,& $+(-f,$3) *,0,w).data == 0) && ($hfind($1,& $+(-f,$3) *,0,w).data == 0) {

      ; increase item 'last'
      hinc -m $1 last

      if ($left($3,2) == -f) || (!$ial) || (!$ial($3)) {

        hadd -m $1 $hget($1,last) $hget($1,last) $3-
      }

      else {

        hadd -m $1 $hget($1,last) $hget($1,last) $ial($3) $4-

        .ialmark $gettok($3,1,33) $ial($gettok($3,1,33)).mark $+(putkick-,$hash($lower($2),32),-,$hget($1,last))
      }
    }
  }

  ; called as identifier ($alias) and propertie is next ($alias().next)
  elseif ($isid) && ($prop == next) && ($hget($1)) {

    ; increase item 'first'
    hinc -m $1 first

    ; 'first' is smaller or equal to 'last'
    if ($hget($1,first) <= $hget($1,last)) {

      ; store next item in var '%next'
      var %next = $hget($1,$hget($1,first))

      ; delete this item from the hashtable
      hdel $1 $hget($1,first)

      ; this is the last item
      if ($hget($1,first) >= $hget($1,last)) {

        ; free the hash table
        hfree $1
      }

      ; return '%next'
      return %next
    }
  }

  ; called as identifier ($alias) and propertie is size ($alias().size)
  elseif ($isid) && ($prop == size) {

    ; decrease number of items with 1, (1 item in queue, and last is there)
    return $iif($calc($hget($1,0).item -1) >= 0,$ifmatch,0)
  }

  ; called as identifier ($alias) and propertie is clear ($alias().clear)
  elseif ($isid) && ($prop == clear) {

    ; free hashtables that match $1
    hfree -w $1
  }
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DISCONNECT EVENT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
on *:disconnect:{

  ; clear the queues
  putkick -c
}


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PUSHMODE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;info:
;
; by wiebe @ QuakeNet
; version 1.31 (written and tested on mIRC 6.15)
;
; last edit: Fri Apr 30 2004
;
;
;What does this script do?
;
; Queues and dumps modes together as much as possible.
;
;
;Some examples:
;
; Example 1: from within same command
; voicing some users with the following command:
; //var %x = $nick($chan,0,r) | while (%x) { mode $chan +v $nick($chan,%x,r) | dec %x }
; and this happens:
;
; [18:45:32] * dev-mirc sets mode: +v zyrtepf
; [18:45:32] * dev-mirc sets mode: +v zcttchv
; [18:45:32] * dev-mirc sets mode: +v yznzko
; [18:45:32] * dev-mirc sets mode: +v yuxf
; [18:45:32] * dev-mirc sets mode: +v twyqh
; [18:45:34] * dev-mirc sets mode: +v pitqxpg
; [18:45:36] * dev-mirc sets mode: +v nsln
; [18:45:38] * dev-mirc sets mode: +v moypfnk
; [18:45:40] * dev-mirc sets mode: +v gibuhee
; [18:45:42] * dev-mirc sets mode: +v evuwntm
;
; This sends a mode command +v <nick> for each nick
;
; Now we do the same but with pushmode instead of the normal mode command:
; //var %x = $nick($chan,0,r) | while (%x) { pushmode $chan +v $nick($chan,%x,r) | dec %x }
; and this happens:
;
; [18:48:03] * dev-mirc sets mode: +vvvvvv zyrtepf zcttchv yznzko yuxf twyqh pitqxpg
; [18:48:04] * dev-mirc sets mode: +vvvv nsln moypfnk gibuhee evuwntm
;
; The modes were now pushed together, so only 2 mode commands are needed instead of 10
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;
;
; Example 2: the same event repeated
; An normal anti-flood script for example does this:
;
; [18:23:32] <zcttchv> AVERAGE ANTI FLOOD SCRIPT WITHOUT PUSHMODE
; [18:23:32] <evuwntm> AVERAGE ANTI FLOOD SCRIPT WITHOUT PUSHMODE
; [18:23:32] <moypfnk> AVERAGE ANTI FLOOD SCRIPT WITHOUT PUSHMODE
; [18:23:33] <zyrtepf> AVERAGE ANTI FLOOD SCRIPT WITHOUT PUSHMODE
; [18:23:33] <gibuhee> AVERAGE ANTI FLOOD SCRIPT WITHOUT PUSHMODE
; [18:23:33] <yznzko> AVERAGE ANTI FLOOD SCRIPT WITHOUT PUSHMODE
; [18:23:33] <yuxf> AVERAGE ANTI FLOOD SCRIPT WITHOUT PUSHMODE
; [18:23:33] <pitqxpg> AVERAGE ANTI FLOOD SCRIPT WITHOUT PUSHMODE
; [18:23:33] <nsln> AVERAGE ANTI FLOOD SCRIPT WITHOUT PUSHMODE
; [18:23:33] <twyqh> AVERAGE ANTI FLOOD SCRIPT WITHOUT PUSHMODE
; [18:23:33] * dev-mirc sets mode: +b *!*qgeqd@8V5Ry4.8vtU30.virtual
; [18:23:33] * dev-mirc sets mode: +b *!*ihgkzu@8V5Ry4.8vtU30.virtual
; [18:23:33] * dev-mirc sets mode: +b *!*dqqyex@8V5Ry4.8vtU30.virtual
; [18:23:36] * dev-mirc sets mode: +b *!*qfzzq@8V5Ry4.8vtU30.virtual
; [18:23:40] * dev-mirc sets mode: +b *!*alavec@8V5Ry4.8vtU30.virtual
; [18:23:44] * dev-mirc sets mode: +b *!*avwy@8V5Ry4.8vtU30.virtual
; [18:23:48] * dev-mirc sets mode: +b *!*tqkukhp@8V5Ry4.8vtU30.virtual
; [18:23:52] * dev-mirc sets mode: +b *!*xrvdohn@8V5Ry4.8vtU30.virtual
; [18:23:56] * dev-mirc sets mode: +b *!*ujundvh@8V5Ry4.8vtU30.virtual
; [18:24:00] * dev-mirc sets mode: +b *!*kid@8V5Ry4.8vtU30.virtual
;
; The anti-flood script sends each ban with a mode command
;
; The same script using pushmode does the following:
;
; [18:25:11] <zcttchv> AVERAGE ANTI FLOOD SCRIPT WITH PUSHMODE
; [18:25:11] <evuwntm> AVERAGE ANTI FLOOD SCRIPT WITH PUSHMODE
; [18:25:11] <moypfnk> AVERAGE ANTI FLOOD SCRIPT WITH PUSHMODE
; [18:25:11] <zyrtepf> AVERAGE ANTI FLOOD SCRIPT WITH PUSHMODE
; [18:25:11] <gibuhee> AVERAGE ANTI FLOOD SCRIPT WITH PUSHMODE
; [18:25:11] <yznzko> AVERAGE ANTI FLOOD SCRIPT WITH PUSHMODE
; [18:25:11] <yuxf> AVERAGE ANTI FLOOD SCRIPT WITH PUSHMODE
; [18:25:11] <pitqxpg> AVERAGE ANTI FLOOD SCRIPT WITH PUSHMODE
; [18:25:11] <nsln> AVERAGE ANTI FLOOD SCRIPT WITH PUSHMODE
; [18:25:12] <twyqh> AVERAGE ANTI FLOOD SCRIPT WITH PUSHMODE
; [18:25:12] * dev-mirc sets mode: +bbbbbb *!*qgeqd@8V5Ry4.8vtU30.virtual *!*ihgkzu@8V5Ry4.8vtU30.virtual *!*dqqyex@8V5Ry4.8vtU30.virtual *!*qfzzq@8V5Ry4.8vtU30.virtual *!*alavec@8V5Ry4.8vtU30.virtual *!*avwy@8V5Ry4.8vtU30.virtual
; [18:25:13] * dev-mirc sets mode: +bbbb *!*tqkukhp@8V5Ry4.8vtU30.virtual *!*xrvdohn@8V5Ry4.8vtU30.virtual *!*ujundvh@8V5Ry4.8vtU30.virtual *!*kid@8V5Ry4.8vtU30.virtual
;
; The anti-flood script sends the modes to pushmode, which turns 10 mode commands into 2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;
;
; Example 3: multiple events
; Some form of a bitchmode script:
;
; on @!*:op:#channel:{ if ($opnick != $me) { mode $chan -o $opnick } }
; on @!*:voice:#channel:{ if ($vnick != $me) { mode $chan -v $vnick } }
; on @!*:help:#channel:{ if ($hnick != $me) { mode $chan -h $hnick } }
; on @!*:mode:#channel:{
; if (n isincs $1) && (n !isincs $gettok($chan($chan).mode,1,32)) { mode $chan +n }
; if (t isincs $1) && (t !isincs $gettok($chan($chan).mode,1,32)) { mode $chan +t }
; }
;
; [13:54:31] * wiebe sets mode: -nt+ovh nick1 nick2 nick3
; [13:54:31] * dev-mirc sets mode: +n
; [13:54:31] * dev-mirc sets mode: +t
; [13:54:31] * dev-mirc sets mode: -o nick1
; [13:54:31] * dev-mirc sets mode: -v nick2
; [13:54:31] * dev-mirc sets mode: -h nick3
;
; With pushmode:
;
; on @!*:op:#channel:{ if ($opnick != $me) { pushmode $chan -o $opnick } }
; on @!*:voice:#channel:{ if ($vnick != $me) { pushmode $chan -v $vnick } }
; on @!*:help:#channel:{ if ($hnick != $me) { pushmode $chan -h $hnick } }
; on @!*:mode:#channel:{
; if (n isincs $1) && (n !isincs $gettok($chan($chan).mode,1,32)) { pushmode $chan +n }
; if (t isincs $1) && (t !isincs $gettok($chan($chan).mode,1,32)) { pushmode $chan +t }
; }
;
; [13:55:36] * wiebe sets mode: -nt+ohv nick1 nick2 nick3
; [13:55:36] * dev-mirc sets mode: -ohv+nt nick1 nick2 nick3
;
; only 1 mode line needed for the 4 events
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;
;
;
;How to use this script?
;
; pushmode [-cdflnprswuNeM] <channel> <+/-mode> [arg]
;
; can be used to push channel modes together, see below
;
;
; The script has 4 different queue's,
; a queue for single modes (like +m) is emptied everytime pushmode is sending modes
; a faster queue, a normal queue (default) and a slower queue for modes with a parameter (like +b banmask)
; first the faster queue is emptied, then the default queue and last the slower queue
;
; The -n switch (next) queues the mode in the faster queue, the -l switch (low) can be used for the slower queue
; this is only for modes with a parameter
; pushmode #channel +v nick adds +v nick to the default queue
; pushmode -l #channel -v nick adds -v nick to the slower queue
; pushmode -n #channel +o nick adds +o nick to the faster queue
;
; The -c switch (clear) can be used to clear the queues
; the -l (low), -d (default), -n (next) and -s (single) switch
; can be used to clear a specific queue or multiple queues
; pushmode -c clears all queues for all channels
; pushmode -dc clears the default queue for all channels
; pushmode -nc #channel clears the faster queue for #channel
; pushmode -cs #channel clears the single queue for #channel
; pushmode -cdl #channel clears the default and slower queue for #channel
;
; The -f switch (flush) starts to empty the queue at once without waiting for the timer to start it
; pushmode -f starts pushmode for all channels
; pushmode -f #channel starts pushmode for #channel
; pushmode -f #channel +o nick starts pushmode for #channel after adding +o nick to the queue
;
; The -p switch (passive) can be used to only add a mode to the queue,
; but it will not cause pushmode to empty the queue,
; this mode will be send the next time pushmode is dumping modes
; or when the number of modes in the queues equals $modespl
; pushmode -p #channel +b queues in the default queue and
; sends +b (request banlist) the next time pushmode is dumping modes
; pushmode -p #channel -b *!*@host.com queues in the default queue and
; sends -b *!*@host.com the next chance it gets
;
; The -r switch (remove) removes a mode from the queue,
; the -l (low), -d (default) and -n (next) switch
; can be used to remove a mode from a specific queue or from multiple queues
; when combined with the -w a wildcardmatch is done
; if you want to clear the entire queue, it is better (read faster) to use the -c switch
; usefull when you want to set a key with pushmode and you first clear any +k and -k modes
; pushmode -dr #channel +b *!*@host.com removes +b *!*@host.com from the default queue
; pushmode -r #channel +v nick removes +v nick from all queues
; pushmode -rw #channel +b * removes all bans from all queues
; pushmode -rw #channel +? removes all single + modes from the queue
; pushmode -rdl #channel +k key removes +k key from the default and slower queue
;
; The -uN switch can be used to remove a ban after N seconds using pushmode
; using 0 for N, makes the script remove the ban from the internal tempban list
; this will not remove the ban from the channel
; pushmode -u120 #channel +b *!*@host.com removes the ban *!*@host.com after 120 seconds
; pushmode -u0 #channel +b *!*@leave.this.ban removes *!*@leave.this.ban from the internal tempban list
;
; The -eM switch (expire) removes the mode from the queue after M seconds,
; so if the mode is not send within M seconds, it will not be send
; pushmode -e10 #channel +m mode +m will only be send within 10 seconds or not
; pushmode -e60 #channel +l 100 mode +l 100 will only be send within 60 seconds or not
;
; Combinations are possible, for example:
; pushmode -nfpe60u600 #channel +b *!*user@*.host.com
;
; The script can voice/devoice users even if they changed nick since the mode was in the queue
; this can be done by giving nick!user@host as parameter
; the default settings makes the script understand that @%+ is ohv, if you are on a server with additional
; modes which can be set on users on a channel, you have to edit the prefix setting below
; the target needs to be in your IAL list for this to work
; the script adds/removes a tag to the IAL using ialmark and finds the nick when sending the mode
; other scripts using ialmark may break this part
;
; pushmode #channel +v goober!~bla@123.abc.isp.com will voice the user goober, even if he would
; change nick before the mode is send
;
; pushmode #channel -h somenick!someuser@abc.users.undernet.org dehalfops somenick, even if he would
; change nick before the mode is send
;
; pushmode #channel +o dev-mirc!dev-mirc@def.users.quakenet.org will op dev-mirc, even if he would
; change nick before the mode is send
;
;
; pushuser <+/-mode> [arg]
;
; can be used for usermodes, usefull if you have several scripts setting usermodes on connect
; pushuser will send them all at once instead of N times a mode command
;
;
; Pushmode (pushuser) can only take 1 mode at a time
; The - or + needs to be included
; The script does not allow duplicates in the same queue
; Temp bans work only if nick!user@host format is used (like *!*@host.com and not *host.com or just host.com)
; this is because of the isban operator
;
; Script is uses $modespl (MODES= setting),
; here meaning how many parameter modes (like +b banmask) can be put into 1 line
; the number of modes without parameter (like +m) is unlimited
; if you want to use this script on a server where this is different, you have to change the script a bit
; see the pushmode.dump alias
;
; Some checks are done on the modes, like if the mode exists, if the mode makes "sense" etc.
; it uses $chanmodes (with b,k,l,imnpst as default modes), checks op/halfop status.
; you can see the checks and change them in the pushmode.dump alias
;
;
;What use has this script?
;
; not only can you simply 'queue' mode changes from within the same event or script
; but mode changes by all scripts can be pushed together
;
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS PUSHMODE.DELAY ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; when first called, the script will wait N seconds before sending a mode change
alias -l pushmode.delay {
  return 0
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS PUSHMODE.RESTART ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; set here the delay (seconds) pushmode should have between multiple mode lines
; after sending a mode change and there are items left in the queue,
; it will wait N seconds before sending the next mode change
alias -l pushmode.restart {
  return 1
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS PUSHMODE.BAN ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; set here the delay (seconds) for checking which bans are to be unset
; a timer runs with this interval
; it checks the temp bans set by this script for all channels and unbans them with pushmode
; settings this to 600 (10 min) for example, makes a temp ban set for 5min being unset after 5~15 minutes
; so this setting defines how accurate the time of a temp ban is
alias -l pushmode.ban {
  return 600
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS PUSHMODE.PREFIX ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; set here what modes can be set on a user on a channel (this is NOT b or any other list mode)
; default @ = o, % = h, + = v
; leave empty if you dont want to use this
; if you are not sure what this is, leave it
; replace each char with their mode char, @ is o for example
alias -l pushmode.prefix {
  return $nickmode
  ; should $nickmode not work, remove it and use the following line
  return $replace($prefix,@,o,%,h,+,v)
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS PUSHMODE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; pushmode [-cdflnprswuNeM] <channel> <+/-mode> [arg]
alias pushmode {
  var %f, %q, %p, %e, %u

  ; part for switches
  if ($left($1,1) == -) {

    ; c switch is there
    if (c isin $1) {

      ; no channel
      if (!$2) {

        ; d switch is there, clear all default queues for this connection
        if (d isin $1) { $pushmode.queue($+($cid,.pushmode.*.default)).clear }

        ; n switch is there, clear all next queues for this connection
        if (n isin $1) { $pushmode.queue($+($cid,.pushmode.*.next)).clear }

        ; l switch is there, clear all low queues for this connection
        if (l isin $1) { $pushmode.queue($+($cid,.pushmode.*.low)).clear }

        ; s switch is there, clear all single queues for this connection
        if (s isin $1) { $pushmode.queue($+($cid,.pushmode.*.single)).clear }

        ; no other switches, clear all queues for this connection
        if (n !isin $1) && (d !isin $1) && (l !isin $1) && (s !isin $1) { $pushmode.queue($+($cid,.pushmode.*)).clear }
      }
      else {

        ; d switch is there, clear the default queue for the channel
        if (d isin $1) { $pushmode.queue($+($cid,.pushmode.,$hash($2,32),.default)).clear }

        ; n switch is there, clear the next queue for the channel
        if (n isin $1) { $pushmode.queue($+($cid,.pushmode.,$hash($2,32),.next)).clear }

        ; l switch is there, clear the low queue for the channel
        if (l isin $1) { $pushmode.queue($+($cid,.pushmode.,$hash($2,32),.low)).clear }

        ; s switch is there, clear the single queue for this connection
        if (s isin $1) { $pushmode.queue($+($cid,.pushmode.,$hash($2,32),.single)).clear }

        ; no other switches, clear all queues for the channel
        if (n !isin $1) && (d !isin $1) && (l !isin $1) && (s !isin $1) {
          $pushmode.queue($+($cid,.pushmode.,$hash($2,32),.next)).clear
          $pushmode.queue($+($cid,.pushmode.,$hash($2,32),.default)).clear
          $pushmode.queue($+($cid,.pushmode.,$hash($2,32),.low)).clear
          $pushmode.queue($+($cid,.pushmode.,$hash($2,32),.single)).clear
        }
      }
      return
    }

    ; f switch is there, set a var
    if (f isin $1) { var %f = 1 }

    ; n switch is there, set a var
    if (n isin $1) { var %q = next }

    ; l switch is there, set a var
    elseif (l isin $1) { var %q = low }

    ; p switch is there, set a var
    if (p isin $1) { var %p = 1 }

    ; u or e switch is used, set a var
    if (u isin $1) || (e isin $1) { var %string = $remove($1,-,d,c,f,l,n,p,r,s,w) , %x = 1

      ; loop through all chars
      while (%x <= $len(%string)) {

        ; found u, set a var
        if ($mid(%string,%x,1) == u) { var %y = $calc(%x +1)

          ; as long as it is numbers, set a var, next char
          while ($mid(%string,%y,1) isnum) { var %u = %u $+ $mid(%string,%y,1) | inc %y }
        }

        ; found e, set a var
        if ($mid(%string,%x,1) == e) { var %y = $calc(%x +1)

          ; as long as it is numbers, set a var, next char
          while ($mid(%string,%y,1) isnum) { var %e = %e $+ $mid(%string,%y,1) | inc %y }
        }
        inc %x
      }

      ; '%e' is a number, set a var
      if (%e isnum) { var %e = -e $+ %e }
    }

    ; u switch is there with a number, +b and a banmask, add to the hash table, make it decrease each second
    if (u isin $1) && ($3 == +b) && ($4) && (%u > 0) {
      hadd -m $+($cid,.pushmode.,$hash($2,32),.bans) $4 %u | hdec -c $+($cid,.pushmode.,$hash($2,32),.bans) $4

      ; check the timer, start the timer
      if (!$timer($+($cid,.pushmode.bans))) {
        .timer $+ $cid $+ .pushmode.bans 1 $$pushmode.ban pushmode.tempban
      }
    }

    ; number with u is 0
    if (%u == 0) && ($3 == +b) && ($4) {

      ; check if it is already in the hash table as temp ban, delete it
      if ($hget($+($cid,.pushmode.,$hash($2,32),.bans))) && ($hget($+($cid,.pushmode.,$hash($2,32),.bans),$4)) {
        hdel $+($cid,.pushmode.,$hash($2,32),.bans) $4

        ; check if the hash table is empty, free the hash table
        if ($hget($+($cid,.pushmode.,$hash($2,32),.bans),0).item == 0) {
          hfree $+($cid,.pushmode.,$hash($2,32),.bans)
        }
      }
      return
    }

    ; r switch is there and mode '$3'
    if (r isin $1) && ($3) {

      ; w switch is there
      if (w isin $1) {

        ; no parameter, remove the mode from the single queue
        if ($4 == $null) { pushmode.queue -rw $+($cid,.pushmode.,$hash($2,32),.single) $3 }
        else {

          ; d switch is there, remove the mode from the default queue
          if (d isin $1) { pushmode.queue -rw $+($cid,.pushmode.,$hash($2,32),.default) $3-4 }

          ; n switch is there, remove the mode from the next queue
          if (n isin $1) { pushmode.queue -rw $+($cid,.pushmode.,$hash($2,32),.next) $3-4 }

          ; l switch is there, remove the mode from the low queue
          if (l isin $1) { pushmode.queue -rw $+($cid,.pushmode.,$hash($2,32),.low) $3-4 }

          ; no other switch is there, remove the mode from all queues
          if (n !isin $1) && (d !isin $1) && (l !isin $1) {
            pushmode.queue -rw $+($cid,.pushmode.,$hash($2,32),.next) $3-4 | pushmode.queue -rw $+($cid,.pushmode.,$hash($2,32),.low) $3-4 | pushmode.queue -rw $+($cid,.pushmode.,$hash($2,32),.default) $3-4
          }
        }
      }
      else {

        ; no parameter, remove mode from the single queue
        if ($4 == $null) { pushmode.queue -r $+($cid,.pushmode.,$hash($2,32),.single) $3 }
        else {

          ; d switch is there, remove mode form the default queue
          if (d isin $1) { pushmode.queue -r $+($cid,.pushmode.,$hash($2,32),.default) $3-4 }

          ; n switch is there, remove mode form next queue
          if (n isin $1) { pushmode.queue -r $+($cid,.pushmode.,$hash($2,32),.next) $3-4 }

          ; l switch is there, remove mode form the low queue
          if (l isin $1) { pushmode.queue -r $+($cid,.pushmode.,$hash($2,32),.low) $3-4 }

          ; no other switch is there, remove mode form all queues
          if (n !isin $1) && (d !isin $1) && (l !isin $1) && (s !isin $1) {
            pushmode.queue -r $+($cid,.pushmode.,$hash($2,32),.next) $3-4 | pushmode.queue -r $+($cid,.pushmode.,$hash($2,32),.low) $3-4 | pushmode.queue -r $+($cid,.pushmode.,$hash($2,32),.default) $3-4
          }
        }
      }
      return
    }
    tokenize 32 $2-
  }

  ; leave multiple modes out
  tokenize 32 $1 $left($2,2) $3

  ; '$2' starts with '+' or with '-', we are on channel '$1'
  if ($istok(+ -,$left($2,1),32)) && ($me ison $1) {

    ; '$3' does exist
    if ($3 != $null) {

      ; -n switch was used, queue mode '$2 $3' in the next queue
      if (%q == next) { pushmode.queue %e $+($cid,.pushmode.,$hash($1,32),.next) $2-3 }

      ; -l switch was used, queue mode '$2 $3' in the low queue
      elseif (%q == low) { pushmode.queue %e $+($cid,.pushmode.,$hash($1,32),.low) $2-3 }

      ; use default queue, queue mode '$2 $3' in the 'default' queue
      else { pushmode.queue %e $+($cid,.pushmode.,$hash($1,32),.default) $2-3 }
    }

    ; the mode does not have a parameter, queue mode '$2' it in the single queue
    else { pushmode.queue $+($cid,.pushmode.,$hash($1,32),.single) $2 }

    ; check if the timer is not already running and check the -p switch, start the timer
    if (!$timer($+($cid,.pushmode.,$hash($1,32)))) && (%p != 1) {
      .timer $+ $cid $+ .pushmode. $+ $hash($1,32) 1 $$pushmode.delay pushmode.dump $1
    }

    ; no timer, and passive switch, set a var
    if (!$timer($+($cid,.pushmode.,$hash($1,32)))) && (%p == 1) {
      var %x = 1, %queue = .next .default .low, %q = 1, %t = 0

      ; loop through each queue, inc var, next queue
      while ($gettok(%queue,%q,32)) {
        inc %t $pushmode.queue($+($cid,.pushmode.,$hash($1,32),$gettok(%queue,%q,32)) ).size | inc %q
      }

      ; at least $modespl modes in the queues, start the timer
      if (%t >= $modespl) {
        .timer $+ $cid $+ .pushmode. $+ $hash($1,32) 1 $$pushmode.delay pushmode.dump $1
      }
    }

    ; f switch was used
    if (%f == 1) {

      ; no channel, set a var
      if (!$1) { var %x = $chan(0)

        ; loop through all the channels, stop the timer, run 'pushmode.dump chan', decrease '%x' and go on to the next channel
        while (%x) {
          .timer $+ $+($cid,.pushmode.,$hash($chan(%x),32)) off | pushmode.dump $chan(%x) | dec %x
        }
      }

      ; we are on '$1', stop the timer, run 'pushmode.dump $1'
      elseif ($me ison $1) {
        .timer $+ $+($cid,.pushmode.,$hash($1,32)) off | pushmode.dump $1
      }
    }
  }
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS PUSHMODE.DUMP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; $1 = #channel
alias -l pushmode.dump {

  ; we are on channel '$1', set vars
  if ($me ison $1) { var %x = 1, %queue = .next .default .low, %q = 1, %mode, %check, %smode

    ; loop through each queue
    while ($gettok(%queue,%q,32)) {

      ; we loop as long as '%x' <= '$modespl' and as long as the size of the queue is greater then 0
      while (%x <= $modespl) && ($pushmode.queue($+($cid,.pushmode.,$hash($1,32),$gettok(%queue,%q,32) )).size > 0) {

        ; save the next item in a var
        var %next = $pushmode.queue($+($cid,.pushmode.,$hash($1,32),$gettok(%queue,%q,32)) ).next

        ; check if mode is not already going to be set
        if (!$istokcs(%check,%next,44)) && (%next) { var %1 = $gettok(%next,1,32), %2 = $gettok(%next,2,32)

          ; some checks / examples of checks
          if (%1 === +o) && (%2 isop $1) { }
          elseif (%1 === -o) && (%2 !isop $1) { }
          elseif (%1 === +h) && (%2 ishop $1) { }
          elseif (%1 === -h) && (%2 !ison $1) { }
          elseif (%1 === +v) && (%2 isvoice $1) { }
          elseif (%1 === -v) && (%2 !ison $1) { }
          elseif (%1 === +b) && (%2 isban $1) { }
          elseif (%1 === +l) && ((%2 !isnum) || (%2 < 1)) { }
          elseif (%1 === +l) && (%2 == $chan($1).limit) { }
          elseif (%1 === +k) && ($chan($1).key) { }
          elseif (%1 === -k) && (%2 !=== $chan($1).key) { }
          elseif ($right(%1,1) === o) && ($me !isop $1) { }
          elseif ($right(%1,1) === h) && ($me !isop $1) { }
          elseif ($me !isop $1) && ($me !ishop $1) { }

          ; add '%next' to '%check', add the mode in the var
          else { var %check = $addtok(%check,%next,44) | var %mode = $+($gettok(%mode,1,32),$gettok(%next,1,32)) $gettok(%mode,2-,32) $gettok(%next,2,32) }
          inc %x
        }
      }
      inc %q
    }

    ; we loop as long as the size of the single queue is greater then 0, set vars
    while ($pushmode.queue($+($cid,.pushmode.,$hash($1,32),.single)).size > 0) {
      var %next = $pushmode.queue($+($cid,.pushmode.,$hash($1,32),.single)).next
      var %a = $+($gettok($chanmodes,1,44),b), %b = $+($gettok($chanmodes,2,44),k)
      var %c = $+($gettok($chanmodes,3,44),l), %d = $+($gettok($chanmodes,4,44),imnpst)

      ; some checks / examples of checks
      if ($right(%next,1) isincs %b) { }
      elseif ($right(%next,1) isincs %c) && ($left(%next,1) == +) { }
      elseif ($right(%next,1) isincs %b) { }
      elseif ($me !isop $1) && ($me !ishop $1) && ($right(%next,1) !isincs %a) { }

      ; add next mode to the var
      else { var %smode = $+(%smode,%next) }
    }

    ; if the ibl isnt filled for that channel, add +b to request the banlist
    ; if you want this uncomment the following line
    ;if (b !isincs %smode) && (!$chan($1).ibl) { var %smode = $+(%smode,+b) }

    ; add the mode in the var
    var %mode = $+($gettok(%mode,1,32),%smode) $gettok(%mode,2-,32)

    ; there are modes in '%mode', send the modes
    if (%mode) { .quote MODE $1 %mode }
    var %q = 1

    ; loop through the queues
    while ($gettok(%queue,%q,32)) {

      ; items left, break
      if ($pushmode.queue($+($cid,.pushmode.,$hash($1,32),$gettok(%queue,%q,32) )).size > 0) { break }
      inc %q
    }

    ; loop was ended with break, start the timer
    if (%q <= $numtok(%queue,32)) {
      .timer $+ $cid $+ .pushmode. $+ $hash($1,32) 1 $$pushmode.restart pushmode.dump $1
    }
  }
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS PUSHUSER ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; $1 = +/-mode, $2 = param
alias pushuser {

  ; remove multiple modes, only use the 1st one given
  tokenize 32 $left($1,2) $2

  ; '$2' is 2 chars long and '$1' starts with '+' or with '-'
  if ($len($1) == 2) && ($istok(+ -, $left($1,1),32)) {

    ; '$2' exists, add the mode to the user queue
    if ($2 != $null) { pushmode.queue $+($cid,.user) $1-2 }

    ; '$2' does not exist, add the mode to the user queue
    else { pushmode.queue $+($cid,.user) $1 }

    ; check if the timer already runs, start the timer
    if (!$timer($+($cid,.pushuser))) {
      .timer $+ $cid $+ .pushuser 1 $$pushmode.delay pushuser.dump
    }
  }
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS PUSHUSER.DUMP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
alias -l pushuser.dump {

  ; loop as long as there are items in the user queue, set a var with the next item, add the mode to the var
  while ($pushmode.queue($+($cid,.user)).size > 0) { var %next = $pushmode.queue($+($cid,.user)).next
  var %mode = $+($gettok(%mode,1,32),$gettok(%next,1,32)) $gettok(%mode,2-,32) $gettok(%next,2,32) }

  ; if '%mode' exists, send the modes
  if (%mode) { .quote MODE $me %mode }
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS PUSHMODE.QUEUE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; pushmode.queue [-eNrw] table mode param
alias -l pushmode.queue {
  var %e

  ; switch is used
  if ($left($1,1) == -) {

    ; got a switch, there are numbers, set a var
    if (e isin $1) { if ($right($1,-2) isnum) { var %e = $+(-u,$right($1,-2)) } }

    ; r switch, w switch, set var
    if (r isin $1) { if (w isin $1) { var %x = $hfind($2,$3-4,0,w).data
        while (%x) {

          ; check hash table, delete
          if ($gettok($hget($2,$hfind($2,$3-4,%x,w).data),1,32) === $3) || ($3 iswm $gettok($hget($2,$hfind($2,$3-4,%x,w).data),1,32)) {
            hdel $2 $hfind($2,$3-4,%x,w).data
          }
          dec %x
        }
      }

      ; no w switch, set vars
      else {
        var %param = $replace($4,\,\\,|,\|,$chr(40),$+(\,$chr(40)),$chr(41),$+(\,$chr(41)), $chr(91),$+(\,$chr(91)),$chr(93),$+(\,$chr(93)),^,\^,$chr(123),$+(\,$c hr(123)),$chr(125),$+(\,$chr(125)),.,\.,$,\$,+,\+,*,\*,?,\?)
        var %mode = \ $+ $left($3,1) $+ $chr(91) $+ $replace($left($3,2),\,\\,|,\|,$chr(40),$+(\,$chr(40)),$chr(41),$+(\,$ chr(41)),$chr(91),$+(\,$chr(91)),$chr(93),$+(\,$chr(93)),^,\^,$chr(123 ),$+(\,$chr(123)),$chr(125),$+(\,$chr(125)),.,\.,$,\$,+,\+,*,\*,?,\?) $+ $chr(93)

        ; check hash table, delete
        if ($hfind($2,%mode %param,1,r).data) { hdel $2 $hfind($2,%mode %param,1,r).data }
      }

      ; 1 item left, free hash table
      if ($hget($2,0).item == 1) { hfree $2 }
      return
    }
    tokenize 32 $2-4
  }

  ; mode is a usermode, it matches *!*@* and no * or ? are there, and its not for the umode queue
  if ($right($2,1) isin $pushmode.prefix) && (*!*@* iswm $3) && (* !isin $3) && (? !isin $3) && (*.user !iswm $1) {

    ; the user is in the ial, add tag to ialmark, tokenize
    if ($ial($gettok($3,1,33))) {
      .ialmark $gettok($3,1,33) $ial($gettok($3,1,33)).mark $+($1,.,$iif($hget($1,last),$calc($ifmatch +1),1))
      tokenize 32 $1 $2 $+(*!,$gettok($3,2,33))
    }

    ; user is not in ial, tokenize
    else { tokenize 32 $1 $2 $gettok($3,1,33) }
  }

  ; set a var, prefix special chars in a regex with a \
  var %param = $replace($3,\,\\,|,\|,$chr(40),$+(\,$chr(40)),$chr(41),$+(\,$chr(41)), $chr(91),$+(\,$chr(91)),$chr(93),$+(\,$chr(93)),^,\^,$chr(123),$+(\,$c hr(123)),$chr(125),$+(\,$chr(125)),.,\.,$,\$,+,\+,*,\*,?,\?)
  var %mode = \ $+ $left($2,1) $+ $chr(91) $+ $replace($left($2,2),\,\\,|,\|,$chr(40),$+(\,$chr(40)),$chr(41),$+(\,$ chr(41)),$chr(91),$+(\,$chr(91)),$chr(93),$+(\,$chr(93)),^,\^,$chr(123 ),$+(\,$chr(123)),$chr(125),$+(\,$chr(125)),.,\.,$,\$,+,\+,*,\*,?,\?) $+ $chr(93)

  ; there is a 2nd parameter and mode '%mode %param' is not already in the queue, where '%mode' is case sensitive
  if ($2 != $null) && ($hfind($1,%mode %param,0,r).data == 0) {

    ; increase item 'last', add mode '$2-' to the hashtable with item name that 'last' has
    hinc -m $1 last | hadd $+(-m,%e) $1 $hget($1,last) $2-
  }

  ; propertie is next and hash table '$1' exists, increase item 'first'
  elseif ($isid) && ($prop == next) && ($hget($1)) { hinc -m $1 first

    ; 'first' is smaller or equal to 'last', set vars
    if ($hget($1,first) <= $hget($1,last)) {
      var %next = $hget($1,$hget($1,first)), %number = $hget($1,first)
      var %mode = $gettok(%next,1,32), %param = $gettok(%next,2,32)

      ; mode is a usermode, parameter matches *!*@*, set var
      if ($right(%mode,1) isin $pushmode.prefix) && (*!*@* iswm %param) {
        var %x = $ial(%param,0)
        while (%x) { var %nick = $ial(%param,%x).nick

          ; the tag is there, remove it, set var, stop loop
          if ($wildtok($ial(%nick).mark,$+($1,.,%number),1,32)) {
            .ialmark %nick $remove($ial(%nick).mark,$ifmatch)
            var %next = %mode %nick | break
          }
          dec %x
        }

        ; no matches found, clear var
        if (%x == 0) { var %next = $null }
      }

      ; delete this item from the hashtable
      hdel $1 $hget($1,first)

      ; this is the last item, free the hash table
      if ($hget($1,first) >= $hget($1,last)) { hfree $1 }
      return %next
    }
  }

  ; called as identifier ($alias) and propertie is size ($alias().size)
  ; decrease number of items with 1, (1 item in queue, and last is there)
  elseif ($isid) && ($prop == size) { return $iif($calc($hget($1,0).item -1) >= 0,$ifmatch,0) }

  ; called as identifier ($alias) and propertie is clear ($alias().clear), free hashtables that match $1
  elseif ($isid) && ($prop == clear) { hfree -w $1 }
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS PUSHMODE.TEMPBAN ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
alias -l pushmode.tempban {
  var %x = 1

  ; loop through the channels
  while (%x <= $chan(0)) {

    ; loop as long as a match is found, items with values 0 or lower
    while ($hfind($+($cid,.pushmode.,$hash($chan(%x),32),.bans),/^[0-]/,1,r).dat a) {

      ; ibl is not filled, or the ban is set, use pushmode to remove the ban
      if (!$chan(%x).ibl) || ($hfind($+($cid,.pushmode.,$hash($chan(%x),32),.bans),/^[0-]/,1,r).dat a isban $chan(%x)) {
        pushmode $chan(%x) -b $hfind($+($cid,.pushmode.,$hash($chan(%x),32),.bans),/^[0-]/,1,r).data
      }

      ; del the item from the hash table
      hdel $+($cid,.pushmode.,$hash($chan(%x),32),.bans) $hfind($+($cid,.pushmode.,$hash($chan(%x),32),.bans),/^[0-]/,1,r).data
    }

    ; check if hash table is empty and the hash table exists, remove hash table
    if ($hget($+($cid,.pushmode.,$hash($chan(%x),32),.bans),0).item == 0) && ($hget($+($cid,.pushmode.,$hash($chan(%x),32),.bans))) {
      hfree $+($cid,.pushmode.,$hash($chan(%x),32),.bans)
    }
    inc %x
  }

  ; start the timer
  .timer $+ $cid $+ .pushmode.bans 1 $$pushmode.ban pushmode.tempban
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DISCONNECT EVENT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
on *:disconnect: { pushmode -c }
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IAL-UPDATE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;info:
;
; by wiebe @ QuakeNet
; version 1.0 (written and tested on mIRC 6.15)
;
; last edit: Sun Jun 06 2004
;
;
;What does this script do?
;
; updates the IAL by doing /who chan1,chan2,chan3 etc
; if a channel is too big, /who nick1,nick2,nick3 etc is done untill the IAL for the channel is updated
; script updates from smallest to the biggest channel
;
;
;How to use this script?
;
; config the options below
; /ialupdate can be used to make the script update the IAL without waiting for the timer to trigger it
;
;
;Why is this script good?
;
; sending /who chan for every channel is not needed and goes slow (lag)
; sending /who chan on join may cause Excess Flood or Max sendQ exceeded
; sending /who chan1,chan2,chan3 can be much faster, but only if there are not too many results (Max sendQ exceeded)
;
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS MAX.WHO ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
alias -l max.who {
  ; maximum number of replies in a WHO, too big may cause 'Max sendQ exceeded' disconnection
  ; too low may take the script a long time to update the IAL, 500 or 400 should be fine for most situations
  !return 700
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS LEN.WHO ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
alias -l len.who {
  ; maximum length of the /who <string>, too long may cause the server to ignore the command
  ; too low may slow things down, 400 should be fine in most cases
  !return 400
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS DELAY.WHO ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
alias -l delay.who {
  ; N seconds after the first join, the script starts to update the IAL
  !return 120
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS REPEAT.WHO ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
alias -l repeat.who {
  ; wait N seconds after doing /who to do the next check and /who
  !return 30
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS SHOW ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
alias -l show.who {
  ; set this to 1 if you want the script to echo when the IAL is updated
  ; shows number of opers, number of users that are away, number of users that are deaf (+d),
  ; number of users that have fake host (+x)
  ; may slow things down, needs some checks / loops etc
  ; only shows when a whole channel is being who'd
  !return 1
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; JOIN EVENT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
on *:join:#:{

  ; we join, IAL not updated, timer does not run, start a timer
  if ($nick == $me) && (!$timer($+($cid,.ial-update.update))) {
    .!timer $+ $cid $+ .ial-update.update 1 $$delay.who ial-update.update
  }
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LOAD EVENT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
on *:load:{ !scon -am1 .!timer $!+ $!cid $!+ .ial-update.update 1 $$delay.who ial-update.update }

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS IALUPDATE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
alias ialupdate { !echo -a IAL-update: $ial-update.update }

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS IAL-UPDATE.UPDATE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
alias -l ial-update.update {
  !var %c, %n

  ; IAL is set on
  if ($ial) {

    ; hash table does not exist, set a var with the channels we need to who
    if (!$hget($+(ial-update.,$cid))) { !var %c = $ial-update.chan($max.who,$len.who)

      ; something is in there, send it to the hash alias, send the who request
      if (%c) { ial-update.hash %c | .!quote WHO %c }

      ; else no channels to who, set a var with the nicks we need to who
      else { !var %n = $ial-update.nick($max.who,$len.who)

        ; something is in there, send it to the hash alias, send the who request
        if (%n) { ial-update.hash %n | .!quote WHO %n }
      }
    }

    ; we did a who or the hash table was not empty, start a timer to run this alias again
    if (%c) || (%n) || ($hget($+(ial-update.,$cid))) {
      .!timer $+ $cid $+ .ial-update.update 1 $$repeat.who ial-update.update
    }

    ; return some info
    if (%c) || (%n) { !return updating }
    elseif ($hget($+(ial-update.,$cid))) { !return already in progress }
    else { !return nothing to update }
  }

  ; ial is off return some info
  else { !return ERROR, IAL is turned off, /IAL on to enable }
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS IAL-UPDATE.SORT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; $ial-update.sort
; sorts channels where the IAL is not updated
; <number of nicks>.<channel number>
; 127.1 <= means 127 users on channel 1
alias -l ial-update.sort {
  !var %x = 1, %c

  ; loop through all common channels that we have with ourself
  ; $chan(0) returns the number of open channel windows,
  ; which does not mean you are on it ("keep channels open" option)
  while (%x <= $comchan($me,0)) {

    ; check if the ial is not updated or busy, add it to a var
    if ($chan($comchan($me,%x)).ial == $false) { !var %c = $addtok(%c,$+($nick($comchan($me,%x),0),.,%x),32) }
    !inc %x
  }

  ; return it sorted
  !return $sorttok(%c,32,n)
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS IAL-UPDATE.MAX ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; $ial-update.max(N)
; N maximum number of nicks to request at once
; this alias returns the channels to ial based on the info provided by $ial-update.sort
; #chan1,#chan2,#chan3
alias -l ial-update.max {
  !var %x = 1, %t = 0, %c = $ial-update.sort, %w

  ; loop through the channels and as long as %t smaller then $1, increase %t
  while (%x <= $numtok(%c,32)) && (%t < $1) {
    !inc %t $gettok($gettok(%c,%x,32),1,46)

    ; if %t is greater then $1, stop the loop
    if (%t > $1) { !break }

    ; add it to a var
    !var %w = $addtok(%w,$gettok($gettok(%c,%x,32),2,46),32)
    !inc %x
  }
  !return %w
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS IAL-UPDATE.CHAN ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; $ial-update.chan(N,L)
; N maximum number of nicks to request at once
; L maximum length of the WHO request
; this alias is used to WHO channels
alias -l ial-update.chan {
  !var %x = 1, %l = 0, %c = $ial-update.max($1), %w

  ; loop through the channels, as long as %l smaller then $2, increase %l for the length of the channel
  while (%x <= $numtok(%c,32)) && (%l < $2) {
    !inc %l $len(%chan)

    ; %l greater then $2, stop the loop
    if (%l > $2) { !break }

    ; add it to the var
    !var %w = $addtok(%w,$comchan($me,$gettok(%c,%x,32)),44)
    !inc %x
  }
  !return %w
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS IAL-UPDATE.NICK ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; $ial-update.nick(N,L)
; N maximum number of nicks to request at once
; L maximum length of the WHO request
; this alias is used to WHO nicks
alias -l ial-update.nick {
  !var %x = 1

  ; loop through the channels untill we found one where the IAL isnt updated
  while ($chan($comchan($me,%x)).ial != $false) && (%x <= $comchan($me,0)) {
    !inc %x
  }

  ; ial is not updated, set vars
  if ($chan($comchan($me,%x)).ial == $false) { !var %y = 1, %t = 0, %l = 0, %w

    ; loop
    while (%t <= $1) && (%l < $2) && (%y <= $nick($comchan($me,%x),0)) {

      ; ial for that nick isnt updated, increase %l
      if (!$ial($nick($comchan($me,%x),%y))) {
        !inc %l $len($nick($comchan($me,%x),%y))

        ; if greater then $2, stop the loop
        if (%l > $2) { !break }

        ; add it to the var
        !var %w = $addtok(%w,$nick($comchan($me,%x),%y),44)
      }
      !inc %y
    }
    !return %w
  }
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS IAL-UPDATE.HASH ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; /ial-update.hash <things> -remove
alias -l ial-update.hash {

  ; $2 is not there, set a var
  if ($2 == $null) { !var %x = $numtok($1,44)

    ; loop through each part seperated with a comma, add it to a hash table
    while (%x) { !hadd -m $+(ial-update.,$cid) $gettok($1,%x,44) 1 | !dec %x }

    ; add mask
    !hadd -m $+(ial-update.,$cid) -mask $1
  }

  ; $2 is -remove, set a var
  elseif ($2 == -remove) { !var %x = $numtok($1,44)

    ; loop through each part seperated with a comma, remove it from the hash table
    while (%x) { if ($hget($+(ial-update.,$cid))) { !hdel $+(ial-update.,$cid) $gettok($1,%x,44) } | !dec %x }

    ; del mask
    !hdel $+(ial-update.,$cid) -mask

    ; check hash table, free hash table
    if ($hget($+(ial-update.,$cid),0).item == 0) && ($hget($+(ial-update.,$cid))) { !hfree $+(ial-update.,$cid) }
  }
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; RAW 352 WHO ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; 352 <you> <channel> <user> <host> <server> <nick> <flags> :<distance> <realname>
raw 352:& & & & & & & & *: {

  ; chan or nick are in the hash table
  if ($hget($+(ial-update.,$cid),$2)) || ($hget($+(ial-update.,$cid),$6)) {

    ; check setting, set a var
    if ($show.who == 1) && ($hget($+(ial-update.,$cid),$2)) && ($comchan($6,0)) { !var %x = $comchan($6,0)

      ; loop, set a var
      while (%x) { !var %c = $comchan($6,%x)

        ; check has table
        if ($hget($+(ial-update.,$cid),%c)) {

          ; * meaning oper isin $7, increase
          if (* isin $7) { !hinc $+(ial-update.,$cid) $+(%c,$chr(44),oper) }

          ; G meaning Gone isin $7, increase
          if (G isincs $7) { !hinc $+(ial-update.,$cid) $+(%c,$chr(44),away) }

          ; d meaning deaf isin $7, increase
          if (d isincs $7) { !hinc $+(ial-update.,$cid) $+(%c,$chr(44),deaf) }

          ; x meaning fake host isin $7, increase
          if (x isincs $7) { !hinc $+(ial-update.,$cid) $+(%c,$chr(44),xhost) }
        }
        !dec %x
      }
    }

    ; stop mirc from showing this raw
    !haltdef
  }
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; RAW 315 WHO END ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; raw 315 <you> <requested> :End of /who list.
raw 315:& & end of /WHO list.: {

  ; check -mask in hash table
  if ($hget($+(ial-update.,$cid),-mask) == $2) {

    ; check setting, set a var
    if ($show.who == 1) { !var %x = $numtok($2,44)

      ; loop, we are on the channel, set var
      while (%x) { if ($me ison $gettok($2,%x,44)) { !var %c = $gettok($2,%x,44)

          ; oper info
          !var %oper = $iif($hget($+(ial-update.,$cid),$+(%c,$chr(44),oper)),$ifmatch,0)
          !var %oper = %oper / $round($calc(%oper / $nick(%c,0) * 100),1) $+ % Oper

          ; away info
          !var %away = $iif($hget($+(ial-update.,$cid),$+(%c,$chr(44),away)),$ifmatch,0)
          !var %away = %away / $round($calc(%away / $nick(%c,0) * 100),1) $+ % Away

          ; deaf info
          !var %deaf = $iif($hget($+(ial-update.,$cid),$+(%c,$chr(44),deaf)),$ifmatch,0)
          !var %deaf = %deaf / $round($calc(%deaf / $nick(%c,0) * 100),1) $+ % deaf

          ; xhost info
          !var %xhost = $iif($hget($+(ial-update.,$cid),$+(%c,$chr(44),xhost)),$ifmatch,0)
          !var %xhost = %xhost / $round($calc(%xhost / $nick(%c,0) * 100),1) $+ % x-host

          ; echo
          !echo -t $gettok($2,%x,44) * IAL updated ( $+ %oper ---- %away ---- %deaf ---- %xhost $+ )
        }

        ; remove from hash table
        !hdel $+(ial-update.,$cid) $+(%c,$chr(44),oper) | !hdel $+(ial-update.,$cid) $+(%c,$chr(44),away)
        !hdel $+(ial-update.,$cid) $+(%c,$chr(44),deaf) | !hdel $+(ial-update.,$cid) $+(%c,$chr(44),xhost)
        !dec %x
      }
    }

    ; remove the items from the hash table
    ial-update.hash $2 -remove
    !haltdef
  }
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DISCONNECT EVENT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
on *:disconnect:{ if ($hget($+(ial-update.,$cid))) { !hfree $+(ial-update.,$cid) } }
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IBL-UPDATE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;info:
;
; by wiebe @ QuakeNet
; version 1.0 (written and tested on mIRC 6.14)
;
; last edit: Fri Mar 26 2004
;
;
;What does this script do?
;
; updates the IBL
;
;
;How to use this script?
;
; config the options below
;
;
;Why is this script good?
;
; script will request the banlist for channel according to your highest prefix on the channel
; meaning, @ (op) goes before % (halfop), then + (voice) and regular as last
; or whatever prefixes are supported on the server, script uses $prefix identifier
;
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS IBL-UPDATE.CONF.DELAY ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
alias -l ibl-update.conf.delay {
  ; N seconds after the last join, the script starts to update the IBL
  return 30
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS IBL-UPDATE.CONF.REPEAT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
alias -l ibl-update.conf.repeat {
  ; wait N seconds after doing /mode chan +b to do the next
  return 15
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS IBL-UPDATE.CONF.SHOW ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
alias -l ibl-update.conf.show {
  ; set this to 1 if you want the script to echo when the banlist is updated
  return 0
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; JOIN EVENT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
on *:join:#:{

  ; we join, timer does not run
  if ($nick == $me) && (!$timer($+($cid,.ibl-update.update))) {

    ; start a timer
    .timer $+ $cid $+ .ibl-update.update 1 $$ibl-update.conf.delay ibl-update.update
  }
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LOAD EVENT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
on *:load:{

  ; start a timer
  .timer $+ $cid $+ .ibl-update.update 1 $$ibl-update.conf.delay ibl-update.update
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS IBL-UPDATE.UPDATE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
alias -l ibl-update.update {

  ; connected
  if ($status == connected) {

    ; hash table does not exist
    if (!$hget($+(ibl-update.,$cid))) {

      ; set a var with the channels we need to who
      var %c = $ibl-update.sort

      ; something is in there
      if (%c) {

        ; add to hash table
        hadd -m $+(ibl-update.,$cid) chan $comchan($me,%c)

        ; send the who request
        mode $comchan($me,%c) +b
      }
    }

    ; requested banlist or the hash table was not empty
    if (%c) || ($hget($+(ibl-update.,$cid))) {

      ; start a timer to run this alias again
      .timer $+ $$ctimer 1 $ibl-update.conf.repeat ibl-update.update
    }
  }
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS IBL-UPDATE.SORT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; $ibl-update.sort
; sorts channels where the IBL is not updated
; <number of nicks + (prefix value) * 100000>.<channel number>
; example:
; 3000004.1 2000001.2 1000001.3 1.4
; op 4 users chan nr 1 halfop 1 user chan nr 2 voice 1 user chan nr 3 regular 1 user chan nr 4
; or whatever prefixes are on the server
alias -l ibl-update.sort {

  ; called as identifier
  if ($isid) {

    ; set a var
    var %x = 1, %c, %p = $len($prefix), %prefix

    ; loop through the prefixes
    while (%p) {

      ; add to var
      var %prefix = $addtok(%prefix,$mid($prefix,%p,1),46)

      ; next prefix
      dec %p
    }

    ; loop through all common channels that we have with ourself
    while (%x <= $comchan($me,0)) {

      ; check if the ibl is not updated or busy
      if ($chan($comchan($me,%x)).ibl == $false) {

        ; set var with channel
        var %chan = $comchan($me,%x)

        ; set var with number of nicks
        var %nicks = $nick(%chan,0)

        ; set var with our highest prefix on the channel
        var %prefixme = $left($remove($nick(%chan,$me).pnick,$me),1)

        ; set var with place of our highest prefix times 100000
        ; (big, no channel should ever come close to this number of users)
        var %value = $calc($iif($findtok(%prefix,%prefixme,46),$ifmatch,0) * 1000000)

        ; set var with number of nicks + the value based on our highest prefix
        var %nicks = $calc(%nicks + %value)

        ; add to the var
        var %c = $addtok(%c,$+(%nicks,.,%x),32)
      }

      ; go to the next channel
      inc %x
    }

    ; return the channel number with the highest score
    return $gettok($gettok($sorttok(%c,32,nr),1,32),2,46)
  }
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; RAW 367 BANLIST ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; raw 367 me chan ban nick ctime
raw 367:& & & & *:{

  ; check hash table
  if ($hget($+(ibl-update.,$cid),chan) == $2) {

    ; stop raw
    haltdef
  }
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; RAW 368 BANLIST END ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; raw 368 me chan :End of channel ban list
raw 368:& & end of channel ban list*:{

  ; check hash table
  if ($hget($+(ibl-update.,$cid),chan) == $2) {

    ; free hash table
    hfree $+(ibl-update.,$cid)

    ; stop raw
    haltdef

    ; check setting
    if ($ibl-update.conf.show == 1) {

      ; more then 1 ban
      if ($ibl($2,0) > 1) {

        ; echo some info
        echo -ti2 $2 * IBL updated ( $+ $ibl($2,0) bans, newest $ibl($2,1) by $gettok($ibl($2,1).by,1,33) at $asctime($ibl($2,1).ctime, ddd dd mmm yyyy) ( $+ $gettok($duration($calc($ctime - $ibl($2,1).ctime)),1-2,32) ago) $+ )
      }

      ; 1 ban
      elseif ($ibl($2,0) == 1) {

        ; echo some info
        echo -ti2 $2 * IBL updated ( $+ $ibl($2,0) ban, $ibl($2,1) by $gettok($ibl($2,1).by,1,33) at $asctime($ibl($2,1).ctime, ddd dd mmm yyyy) ( $+ $gettok($duration($calc($ctime - $ibl($2,1).ctime)),1-2,32) ago) $+ )
      }

      ; 0 bans
      else {

        ; echo some info
        echo -ti2 $2 * IBL updated (0 bans)
      }
    }
  }
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DISCONNECT EVENT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
on *:disconnect:{

  ; check hash table
  if ($hget($+(ibl-update.,$cid))) {

    ; free hash table
    hfree $+(ibl-update.,$cid)
  }
}