Basic — File Browser

Basicv23042002 / Basicv23042002 / basic / sys / cprot.mrc

cprot.mrc — 19.79 KB — Download this file

; ###################################
;
;  Basic v23042002
;  blue-elf, belf@mircscripter.com
;
;  channel protection
;  requires ulist.mrc
;  this must be the first loaded script!
;
; ###################################

; $_sysflood($network,#channel,wildsite,floodtype,max,secs[,len,text])
; for nick/quit flood, use default for #channel
; main hash table = $network.#channel
; item1 = wildsite.floodtype.Num
; item2 = wildsite.floodtype.Len
; item3 = wildsite.floodtype.Sec
; Using /hadd -m %h Count because hinc -ms doesn't work.

alias _sysflood {
  var %r, %h = $+($1,.,$2), %pre = $+($3,.,$4,.), %n = $+(%pre,Num), %l = $+(%pre,Len), %s = $+(%pre,Sec)
  hadd -m %h %n $calc($hget(%h,%n) + 1)
  if ($8) hadd %h %l $calc($hget(%h,%l) + $len($8-))
  if ($hget(%h,%s) == $null) hadd %h %s $ticks
  if (($7) && ($hget(%h,%l) >= $7)) {
    if ($calc(($ticks - $hget(%h,%s)) / 1000) <= $6) %r = $4 Flood: $hget(%h,%l) chars in $ifmatch $+ / $+ $6 $+ s
    hdel -w %h %pre $+ *
  }
  if ($hget(%h,%n) >= $5) {
    if ($calc(($ticks - $hget(%h,%s)) / 1000) <= $6) %r = $4 Flood: $hget(%h,%n) in $ifmatch $+ / $+ $6 $+ s
    hdel -w %h %pre $+ *
  }
  return %r
}

; /_repeat #channel wildsite nick text
;              $1      $2      $3  $4
alias _repeat {
  var %r, %max = $_sysgo($1,RepeatFloodMax), %sec = $_sysgo($1,RepeatFloodSec)
  var %hash = $+($cid,.,$2), %text = $+($2,.RepeatText), %inc = $+($2,.RepeatCount), %time = $+($2,.RepeatTime)
  if ($strip($4-) === $hget(%hash,%text)) {
    hinc %hash %inc
    if ($hget(%hash,%inc) >= %max) {
      if ($calc(($ticks - $hget(%hash,%time)) / 1000) <= %sec) %r = Repeat Flood: $hget(%hash,%inc) in $+($ifmatch,/,%sec,s)
      $+(.timer.,$cid,.SysRepeat.,$1,$2) -m 1 0 hdel -w %hash $+($2,.Repeat*)
      return %r
    }
  }
  else {
    hadd -m %hash %text $4-
    hadd %hash %time $ticks
    hadd %hash %inc 1
  }
}

; /_ChanFlood <cid> <network> <#channel> <Type> <fulladdress> [text]
;                $1      $2        $3       $4        $5
; Type = Notice CTCP Text
; If Type is Nick, channel is Default <-- needs GlobalKickBan of address
; JoinFlood has to be dealt with differently to match clone prot
alias _chanflood {
  if (($_isex($3,$gettok($5,1,33))) || ($_isuser($2,$3,$5).exempt)) return
  var %type = $+($4,Flood), %mask = $mask($5,2), %nick = $gettok($5,1,33)
  if ($_sysgo($3,%type)) {
    if ($_sysflood($1,$3,%mask,$4,$_sysgo($3,$+(%type,Max)),$_sysgo($3,$+(%type,Sec)),$_sysgo($3,$+(%type,Len)),$6-)) {
      var %k = $ifmatch, %pre = $+($1,.,$3), %item = $+($1,.,%mask,.Inc.,%type)
      hinc -m %pre %item 1
      _react $1 $+($2,.,$3,.,%type) $hget(%pre,%item) $3 %nick $5 %k
    }
  }
}

; NOTE: hload ini settings for protection
; $_sysgetopt(server,#channel,option,network)
; $_sysgo(channel,option)
; $_network <-- Make a new one in case $network fails.

; #change to allow default kick messages
on *:invite:#:{
  if ($srvbot($nick,$address)) return
  var %i = 1, %c, %s = #
  while ($comchan($nick,%i)) {
    %c = $ifmatch
    ; if (%c == %s) break
    if ($me isop %c) {
      if (($_isex(%c,$nick)) || ($_isuser($_network,%c,$fulladdress).exempt)) break
      if ($_sysgo(%c,InviteKick)) {
        var %pre = $+($_network,.,%c,.), %hinc = $+($cid,.,%c), %item = $+($cid,.,$wildsite,.Inc.Invite)
        hinc -m %hinc %item 1
        _react $cid $+(%pre,Invite) $hget(%hinc,%item) %c $nick $fulladdress No invites
      }
    }
    inc %i
  }
}
on @*:text:*:#:_cprot $1-
on @*:action:*:#:_cprot $1-
on @*:notice:*:#:_cprot $1-
ctcp *:*:#:{
  if ($me isop #) {
    _botnetprot $cid $_network # $event
    _chanflood $cid $_network # CTCP $fulladdress $1-
  }
}

alias _isex {
  var %ex = $_sysgo($1,ExemptedList)
  if (((w isin %ex) && ($2 isowner $1)) || ((o isin %ex) && ($2 isop $1)) || ((v isin %ex) && ($2 isvo $1)) || ((n isin %ex) && ($2 !isreg $1))) return 1
}
alias _cprot {
  if (($srvbot($nick,$address)) || ($_isex(#,$nick)) || ($_isuser($_network,#,$fulladdress).exempt)) return
  _botnetprot $cid $_network # $event
  var %pre = $+($_network,.,#,.), %hinc = $+($cid,.,#)
  _chanflood $cid $_network # $replace($event,action,Text) $fulladdress $1-
  if (($_sysgo(#,CtrlKick)) && ($int($calc(($count($1-,,,,,) * 100) / $len($1-))) >= $_sysgo(#,CtrlKickMax))) {
    var %m = $ifmatch, %item = $+($cid,.,$wildsite,.Inc.ControlCodes)
    hinc -m %hinc %item 1
    _react $cid $+(%pre,ControlCodes) $hget(%hinc,%item) # $nick $fulladdress Excess control codes: $+(%m,/,$_sysgo(#,CtrlKickMax),$chr(37))
    if ($result) return
  }
  if (($_sysgo(#,LongWord)) && ($chr(32) !isin $1-) && ($len($strip($1-)) >= $_sysgo(#,LongWordMax))) {
    var %item = $+($cid,.,$wildsite,.Inc.LongWord)
    hinc -m %hinc %item 1
    _react $cid $+(%pre,LongWord) $hget(%hinc,%item) # $nick $fulladdress Learn to use your spacebar: $ifmatch chars.
    if ($result) return
  }
  if (($_sysgo(#,RepeatFlood)) && ($_repeat(#,$wildsite,$nick,$1-))) {
    var %k = $ifmatch, %item = $+($cid,.,$wildsite,.Inc.RepeatFlood)
    hinc -m %hinc %item 1
    _react $cid $+(%pre,RepeatFlood) $hget(%hinc,%item) # $nick $fulladdress %k
    if ($result) return
  }
  ; combination of qwerty's regex and cold's kicker
  if ($_sysgo(#,CapsKick)) {
    var %usr = $calc(100 * $regex($1-,/[A-Z]/g) / $regex($1-,/[A-Z]/gi)), %max = $_sysgo(#,CapsMax)
    if ((%usr > %max) && ($calc($len($1-) - $len($remove($1-,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z))) > 9)) {
      var %item = $+($cid,.,$wildsite,.Inc.CapsKick)
      hinc -m %hinc %item 1
      _react $cid $+(%pre,CapsKick) $hget(%hinc,%item) # $nick $fulladdress Too much CAPS: $+($int(%usr),/,%max,%)
      if ($result) return
    }
  }
  if (($_sysgo(#,SpamKick)) && ($($+(%,Sys.join.new.,$cid,.,#,.,$nick),2)) && ($_isbadword(spam,$_network,#,$1-))) {
    _react $cid $+(%pre,Spam) 1 # $nick $fulladdress Spamming
    if ($result) return
  }
  if (($_sysgo(#,SwearKick)) && ($_isbadword(swear,$_network,#,$1-))) {
    var %w = $ifmatch, %item = $+($cid,.,$wildsite,.Inc.Swear)
    hinc -m %hinc %item 1
    _react $cid $+(%pre,Swear) $hget(%hinc,%item) # $nick $fulladdress You cannot say $_censor(%w) in here
  }
}

alias _sysga {
  var %f = sys\channels.ini, %i = $+($2,$3)
  if (!$readini(%f,n,Main,UseDefaults)) return $readini(%f,n,$1,%i)
  if ($readini(%f,n,$1,%i) != $null) return $ifmatch
  var %net = $gettok($1,1,46), %chan = $gettok($1,2,46), %type = $gettok($1,3,46)
  if ($readini(%f,n,$+(%net,.Default.,%type),%i) != $null) return $ifmatch
  if ($readini(%f,n,$+(Default.,%chan,.,%type),%i) != $null) return $ifmatch
  if ($readini(%f,$+(Default.,$gettok($1,-2-,46)),%i) != $null) return $ifmatch
  return $readini(%f,$+(Default.Default.,$gettok($1,-1,46)),%i)
}
alias -l _warn {
  var %q = $1
  goto %q
  :1  | return .notice $3
  :2  | return .msg $3
  :%q | return msg $2
}
; /_react <cid> <header> <N> <#> <nick> <fulladdress> <kickmsg>
;           $1     $2     $3  $4   $5      $6           $7-
; <header> = Network.#channel.OffenceType
alias _react {
  var %react
  if ($_sysga($2,Ban.,$3)) {
    var %m = $mask($6,$_iif($_sysga($2,BanType.,$3),2))
    if ($_sysga($2,BanTime.,$3)) ban -u $+ $ifmatch $4 %m
    else .raw MODE $4 +b %m
  }
  if ($_sysga($2,Kick.,$3)) {
    var %r = $_sysga($2,KickMsg.,$3)
    if (%r == $null) {
      %r = $_kickmsg($gettok($2,-1,46))
      if ($_sysread(Option,AppendInfo)) %r = %r ( $+ $gettok($7-,2-,58) $+ )
    }
    else %r = $7-
    var %r = $+(:,%r), %react = 1
    if ($istok(JoinFlood QuitFlood NickFlood,$gettok($2,-1,46),32)) {
      var %m = $mask($6,2), %h = $+($1,.,$4)
      hadd -m %h %m $+ .Kick %r
      _sysfk $4 %m %r
      $+(.timer.,$1,.SysRemHash,%m) 1 3 hdel -w %h %m $+ .*
    }
    else {
      if ($5 ison $4) .raw KICK $4-5 %r
      cloneremhost $1 $4-5 $mask($6,2)
    }
  }
  if ($_sysga($2,Custom.,$3)) { if ($_sysga($2,CustomC.,$3)) $replace($ifmatch,!nick,$5,!chan,$4,!address,$gettok($6,2,33)) }
  if ($_sysga($2,Warn.,$3)) {
    if ($_sysga($2,WarnMsg.,$3)) {
      var %w = $ifmatch
      $_warn($_sysga($2,WarnSnd.,$3),$4,$5) %w
    }
  }
  if ($_sysga($2,Ignore.,$3)) {
    var %t = $_sysga($2,IgnoreT.,$3), %t = $iif(%t,$+(-u,%t))
    ignore %t $mask($6,$_iif($_sysga($2,IgnoreM.,$3),3))
  }
  if ($_sysga($2,Beep.,$3)) {
    if ($_isfile($_sysga($2,Sound.,$3))) splay $ifmatch
    else beep
  }
  if ((!$appactive) && ($_sysga($2,Flash.,$3))) flash $gettok($2,-1,46)
  if ($_sysga($2,WarnMe.,$3)) echo $colour(info) -ti $4 *** $gettok($2,-1,46) abuse from $6
  if ($3 >= $_sysga($2,MaxOffence)) hdel $+($1,.,$4) $+($1,.,$mask($6,2),.Inc.,$gettok($2,-1,46))
  return %react
}
; clone/join
; main hash table = id#channel
; item1 = wildsite.floodtype.Num
; item2 = wildsite.floodtype.Len
; item3 = wildsite.floodtype.Sec
on *:join:#:{
  var %h = $_hn(#), %j
  if ($nick == $me) hmake %h 999
  if (($hget(%h,$nick)) && ($hget(%h,netsplit.starttime))) return
  hadd -m %h $nick user
  if ($me !isop #) return
  ; #change to make it faster
  var %net = $_network, %chan = #, %addy = $fulladdress
  if ($_isuser(%net,%chan,%addy).exempt) return
  _botnetprot $cid $_network # $event
  if ($regex($_isbanned(%net,%chan,%addy).flags,(k|b))) .raw MODE # +b $_isbanned(%net,%chan,%addy) $+ $lf $+ KICK # $nick : $+ $_isbanned(%net,%chan,%addy).reason
  var %p = $+($wildsite,.Clone.Prot), %k = $+($wildsite,.Kick)
  if ($hget(%h,%k)) {
    .raw KICK # $nick $ifmatch
    $+(.timer,%h,.,%k) 1 5 hdel %h %k
    unset $($+(%,Sys.join.new.,$cid,.,#,.,$nick))
    return
  }
  _chanflood $cid $_network # Join $fulladdress
  if ($_sysgo(#,SpamKick)) set $+(%,Sys.join.new.,$cid,.,#,.,$nick) 1
  if ($timer($+($cid,.SysRemHash.,$wildsite))) return
  if ($_sysgo(#,CloneKBan)) {
    var %d = KICK # $nick :clones: $wildsite
    hadd -m %h %p $addtok($hget(%h,%p),%d,10)
    if ($numtok($hget(%h,%p),10) >= $_sysgo(#,CloneKBanMax)) {
      hadd -m %h %k :Clones: $wildsite
      var %o = $+($_network,.,#,.Clone), %m = $mask($fulladdress,$_iif($_sysga(%o,BanType.,1),2)), %t = $_sysga(%o,BanTime.,1), %b = $_sysga(%o,Ban.,1), %k2 = $_sysga(%o,Kick.,1), %f = $replace($hget(%h,%p),$wildsite,%m)
      if ((%b) && (%k2)) {
        .raw MODE # +b $+(%m,$lf,%f)
        if (%t) $+(.timer.,$cid,.SysUnban.,#) 1 $ifmatch _unban # %m
        %j = 1
      }
      elseif (%b) {
        if (%t) ban $+(-u,%t) # %m
        else .raw MODE # +b %m
      }
      elseif (%k2) {
        .raw %f
        %j = 1
      }
      if ($_sysga(%o,Custom.,1)) { if ($_sysga(%o,CustomC.,1)) $replace($ifmatch,!nick,$nick,!address,$address,!chan,#) }
      if ($_sysga(%o,Ignore.,1)) {
        var %t = $_sysga(%o,IgnoreT.,1), %t = $iif(%t,$+(-u,%t))
        ignore %t $mask($fulladdress,$_iif($_sysga(%o,IgnoreM.,1),2))
      }
      if ($_sysga(%o,Beep.,1)) {
        if ($_isfile($_sysga(%o,Sound.,1))) splay $ifmatch
        else beep
      }
      if ((!$appactive) && ($_sysga(%o,Flash.,1))) flash Clones
      if ($_sysga(%o,WarnMe.,1)) echo $colour(info) -ti # *** CloneFlood abuse from $fulladdress
      hdel -w %h $wildsite $+ .Clone.*
    }
  }
  if (%j) return
  ; trigger badnick at the end of the whole because it's slower compared to clone/join
  _badnick $cid $_network $chan $nick $fulladdress
}

alias -l _unban if ($me isop $1) mode $1 -b $2
alias -l _hf {
  unset $+(%,Sys.join.new.,$1,.,$2,.,$3)
  if ($3 == $me) _hfree $_hn($2)
  else {
    hdel $_hn($2) $3
    cloneremhost $1-
  }
}
on *:part:#:{
  _hf $cid # $nick $wildsite
  unset $+(%,sys.join.new.,$cid,.,#,.*)
}
on *:kick:#:{
  _hf $cid # $knick $wildsite
  if (($me !isop #) || ($_isex(#,$knick))) return
  if (!$_isex(#,$nick)) _chanflood $cid $_network # MassKick $address($nick,5)
  if ($_sysgo(#,BanRepeatOffender)) {
    var %wildsite = $address($knick,2), %max = $_sysgo(#,BanRepeatOffenderMax), %sec = $calc($_sysgo(#,BanRepeatOffenderSec) * 60)
    if (((!%sec) && (!%time)) || ($_isuser($_network,#,$address($knick,5)).exempt)) return
    var %v1 = % $+ _Sys.tmp $cid # %wildsite inc, %v2 = $replace(%v1,inc,sec), %v1 = $replace(%v1,$chr(32),.), %v2 = $replace(%v2,$chr(32),.)
    inc $(%v1)
    if ($(%v1,2) == 1) set $(%v2) $ctime
    elseif ($(%v1,2) >= %max) {
      if ($calc($ctime - $(%v2,2)) <= %sec) {
        var %a = $_trimdur($duration($ifmatch)), %b = $_trimdur($duration(%sec))
        mode # +b %wildsite
        hadd -m $_hn(#) $+(%wildsite,.Kick) :Repeat offender: Kicked $(%v1,2) times in $+(%a,/,%b)
        .timer 1 10 hdel $_hn(#) $+(%wildsite,.Kick)
      }
      unset $(%v1) $(%v2)
    }
  }
}

on *:quit:{
  if ($nick == $me) {
    hfree -w $_hn(*)
    unset $+(%,_Sys.tmp.,$cid,.*) $+(%,Sys.Join.new.,$cid,.*)
  }
  else {
    unset $+(%,sys.join.new.,$cid,.*.,$nick)
    ; regex courtesy of qwerty-
    var %r = ^(?:(?:(?:(?:(?:www[\w\-]+)|(?:ww[^w\W][\w\-]*)|(?:[^w\W]{1}[\w\-]*))\.){2,}[\w\-]{2,4} (?:(?:(?:www[\w\-]+)|(?:ww[^w\W][\w\-]*)|(?:[^w\W]{1}[\w\-]*))\.){2,}[\w\-]{2,4})|(?:\*\.net \*\.split))$
    var %split = $regex($1-,%r)
    var %t, %c, %n = $nick, %w = $wildsite, %i = 1
    while ($comchan(%n,%i)) {
      var %c = $ifmatch, %h = $_hn(%c)
      cloneremhost $cid %c %n %w
      _botnetprot $cid $_network %c $event
      _chanflood $cid $_network %c Quit $fulladdress $1-
      if (!%split) hdel %h %n
      else {
        if (!$hget(%h,%n)) hadd -m $_hn(%c) %n user
        if (!%t) {
          hadd -m $_hn(%c) netsplit.start $ctime
          %t = 1
        }
      }
      inc %i
    }
  }
}
on *:nick:{
  var %i = 1, %o = $nick, %c, %n = $newnick, %full = $+(%n,!,$address), %net = $_network
  while ($comchan(%n,%i)) {
    var %c = $ifmatch, %v = $+(%,Sys.join.new.,$cid,.,%c,.,%o)
    hadd -m $_hn(%c) %n $hget($_hn(%c),%o)
    hdel $_hn(%c) %o
    if ($(%v,2)) {
      unset $(%v)
      set $+(%,Sys.join.new.,$cid,.,%c,.,%n) 1
    }
    _botnetprot $cid $_network %c $event
    _badnick $cid %net %c %n %full
    _chanflood $cid %net %c Nick %full $1-
    inc %i
  }
}
on @*:serverop:#:{
  if (($srvbot($opnick,$address)) || ($_isuser($_network,#,$address($opnick,5)).exempt)) return
  if (d isincs $_isbanned($_network,#,$address($opnick,5)).flags) mode # -o $opnick
  elseif ($_sysgo(#,NetHack)) {
    var %max = $_sysgo(#,NetHackMax)
    if (!%max) mode # -o $opnick
    elseif ($hget($_hn(#),netsplit.start)) if ($calc($ctime - $ifmatch) >= $calc(%max * 60)) mode # -o $opnick
  }
}
on *:op:#:{
  if ($opnick == $me) _kcp #
  if (($me isop #) && (d isincs $_isbanned($_network,#,$address($opnick,5)).flags)) .raw MODE # -o $+($opnick,$lf,NOTICE) $nick $+(:,$opnick) is in my auto-deop list.
  hadd -m $_hn(#) $opnick op
}
on *:deop:#:{
  hadd -m $_hn(#) $opnick user
  if ($me isop #) _chanflood $cid $_network # MassDeop $address($nick,5)
}
on *:dialog:cset:*:*:{
  if (($istok(init mouse,$devent,32)) || ($did == 4)) return
  if (!$did(4).enabled) did -e cset 4
}
on *:disconnect:{
  hfree -w $_hn(*)
  unset $+(%,_Sys.tmp.,$cid,.*) $+(%,sys.join.new.,$cid,.*)
  if (!$_connected) hfree -w _syswordkick.*
}

; /cloneremhost <cid> <Channel> <Nick> <Wildsite>
;
; removes all entries for clone hash tables ONLY
; for the NICK with the wildsite.
;
alias -l cloneremhost {
  var %h = $+($1,.,$2), %p = $+($4,.Clone.Prot), %k = $+($4,.Kick)
  if ($hget(%h,%p)) {
    var %d = $ifmatch, %r = KICK $2-3 :clones: $4
    if ($calc($numtok(%d,10) -1)) hadd %h %p $remtok(%d,%r,10)
    else hdel %h %p
  }
  if ($hget(%h,%k)) hdel %h %k
}
; misc
on @*:ban:#:{
  if (($_sysgo(#,FilterKickOnBan)) && ($nick != $me) && ($_isuser($_network,#,$ialchan($banmask,#,1)).exempt)) {
    var %r = Banned by $nick
    if ($_kickmsg(FilterKick) != $null) %r = $ifmatch
    if ($_sysread(Option,AppendInfo)) %r = %r (Banned)
    _sysfk # $banmask %r
  }
  _chanflood $cid $_network # MassBan $address($nick,5)
}
; /_botnetprot $cid $network $chan $event
;                $1    $2      $3    $4
alias _botnetprot {
  if ($_sysgo($3,$+(BotNet,$4))) {
    var %hash = $+(_FloodNetProt.,$4)
    hinc -m %hash inc 1
    if ($hget(%hash,time) == $null) hadd %hash time $ctime
    elseif ($hget(%hash,inc) >= $_sysgo($3,$+(BotNet,$4,Max))) {
      if ($calc($ctime - $hget(%hash,time)) <= $_sysgo($3,$+(BotNet,$4,Sec))) {
        var %header = $+($2,.,$3,.,BotNet,$4,Flood)
        ; modes
        var %modes = $_sysread(%header,ModesFinal)
        if (!$_sysread(%header,ModesOtherS)) %modes = $removecs(%modes,$_sysread(%header,ModesOtherM))
        if (($me isop $3) && (%modes)) {
          mode $3 %modes $iif(l isincs %modes,$nick($3,0))
          if ((m isincs %modes) && ($_sysread(%header,UndoMode+m))) .timer 1 $ifmatch _omode $3 -m
          if ((i isincs %modes) && ($_sysread(%header,UndoMode+i))) .timer 1 $ifmatch _omode $3 -i
          if ((l isincs %modes) && ($_sysread(%header,UndoMode+l))) .timer 1 $ifmatch _omode $3 -l $chan($3).limit
          if ($removecs(%modes,m,i,l)) {
            var %o = $ifmatch
            if ($_sysread(%header,UndoMode+o)) .timer 1 $ifmatch _omode $3 $replace(%o,+,-)
          }
        }
        ; ignores
        var %s
        if ($_sysread(%header,IgCTCP)) %s = t
        if ($_sysread(%header,IgPMsg)) %s = %s $+ p
        if ($_sysread(%header,IgNtcs)) %s = %s $+ n
        if ($_sysread(%header,IgDCCs)) %s = %s $+ d
        if ($_sysread(%header,IgUndo)) %s = %s $+ u $+ $ifmatch
        if (%s) .ignore %s *
        ; others
        if ($_sysread(%header,CustomTog)) $readini(%file,%header,CustomCom)
        if (($_sysread(%header,Flash)) && (!$appactive)) flash FloodNet - $4
        if (($_sysread(%header,Warn)) && ($3 != $active) && ($1 != $activecid)) scid $activecid echo 4 -a *** Possible floodnet of type: $4
        if ($_sysread(%header,Beep)) {
          if ($_isfile($_sysread(%header,Sound))) splay $shortfn($ifmatch)
          else beep
        }
        if ($_sysread(%header,Clear)) scid $1 clear $3
        hfree %hash
      }
      else {
        hadd %hash time $ctime
        hadd %hash inc 1
      }
    }
  }
}
; extra basic dialog events
; because dialog.mrc is too bloated already.

; kick messages
on *:dialog:basic:init:*:{
  mdxinit $dname 167 81,131 Offence,Message
  var %e = $klist, %i = 1
  while ($gettok(%e,%i,32)) {
    var %item = $ifmatch, %kickmsg = $_iif($_kickmsg(%item), )
    did -a $dname 167 $tab(%item,%kickmsg)
    did -a $dname 176 %item $remove(%kickmsg, )
    inc %i
  }
  if ($_sysread(Option,AppendInfo)) did -c $dname 170
}
; Ok button
on *:dialog:basic:sclick:3:{
  savebuf -o $dname 176 $_datfile(kicks.txt)
  _cset Option AppendInfo $did(170).state
  if ($_connected) _load.kickmsgs
}
on *:dialog:basic:sclick:168:{
  if ($did(167).sel) {
    var %l = $ifmatch
    tokenize 32 $mdxgetline($did(167,%l))
    var %o = $1, %x = $iif($2- !=  ,$2-), %m ,%var = $1 offence
    if ($1 == Repeat) %var = $1 offenders (users who are kicked so many times in a short span of time)
    %m = $input(Enter kick message for %var ,1,Kick message,%x)
    if ((%m) && (%m !=  )) {
      did -o $dname 167 %l $tab(%o,%m)
      did -o $dname 176 $calc(%l - 1) %o %m
    }
  }
  _showdlg basic
}
on *:dialog:basic:sclick:169:{
  if ($did(167).sel) {
    var %l = $ifmatch, %e = $gettok($mdxgetline($did(167,%l)),1,32)
    did -o $dname 167 %l $tab(%e, )
    did -o $dname 176 $calc(%l - 1) %e
  }
}
alias _kickmsg {
  if ($hget(_SysKickMsgs,$1)) return $ifmatch
  return $read($_datfile(kicks.txt),ns,$1)
}
alias -l klist {
  return Filterkick Spam Repeat CapsKick LongWord ControlCodes Clone Invite BadUserHost Swear $&
    TextFlood NoticeFlood CTCPFlood NickFlood RepeatFlood JoinFlood QuitFlood MassDeopFlood MassKick MassBan
}
alias _load.kickmsgs {
  if ($hget(_SysKickMsgs)) return
  var %i = 1, %l = $klist
  while ($gettok(%l,%i,32)) {
    hadd -m _SysKickMsgs $ifmatch $_kickmsg($ifmatch)
    inc %i
  }
}
; end kick messages

; eof