All pastes #766789 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-11-09 04:17 UTC
rendered paste body
alias cscan {
  if (!$chan(0)) { errdialog you are not on any channel you could scan for clones! }
  else {
    if ($1 ischan) { set %cscan.pchan $1 }
    nndlg -m clonescan
  }
}
dialog clonescan {
  title CloneScan on $curconserv [/cscan]
  size -1 -1 364 206
  option pixels
  icon script\pics\nntray.ico
  box "Channel", 2, 4 0 144 48
  combo 7, 12 16 128 144, sort size drop
  box "Statistics", 5, 4 54 144 118
  text "Total users", 15, 14 74 58 16
  edit "", 14, 84 70 56 22, read autohs center
  text "Clones", 8, 14 98 36 16
  edit "", 9, 84 94 56 22, read autohs center
  text "Percentage", 10, 14 122 62 16
  edit "", 11, 84 118 56 22, read autohs center
  text "Scan time", 12, 14 146 50 16
  edit "", 13, 84 142 56 22, read autohs center
  box "Clones (right-click for options)", 4, 156 0 204 172
  list 6, 164 16 188 148, size
  button "&Ok", 1, 280 178 80 24, ok
  menu "&File", 17
  item "&Close", 18, 17
  menu "&Settings", 19
  item "&Update IAL", 20, 19
  item "&Refresh clones", 21, 19
}
on *:dialog:clonescan:*:*:{
  if ($devent == init) {
    mdx SetControlMDX $dname 6 TreeView haslines hasbuttons showsel nohscroll > script\dlls\views.mdx
    var %c = $chan(0)
    while (%c) {
      did -a $dname 7 $chan(%c)
      dec %c
    }
    did -c $dname 7 $iif($didwm(7,$iif(%cscan.pchan,$v1,$active)),$v1,1)
    unset %cscan.pchan
    cscan.do
  }
  elseif ($devent == sclick) {
    if ($did == 7) { cscan.do }
    elseif ($did == 6) {
      tokenize 32 $did($did,1)
      if ($1 == rclick) && ($5) {
        did -i $dname $did 1 cb root $3-4
        did -c $dname 6 $5
        var %c = $did(7).seltext,%o = $iif(!$ccontrol(%c),+d,+),%n
        noop $regsub($wd($gettok($gettok($did($did,$5),2,9),1,13),2),$+(/[,$prefix,]/g),,%n)
        popdll.new popup
        popdll.add popup +d 0 0 — $shorten(10,%n) —
        popdll.add popup
        popdll.add popup + 0 0 Whois $cr we %n
        popdll.add popup
        popdll.add popup %o 0 0 Kick $cr k %c %n Clones are not welcome in %c $+ !
        popdll.add popup %o 0 0 Kickban $cr kb %c %n Clones are not welcome in %c $+ , banned!
        popdll.add popup %o 0 0 Timekickban $cr tkb %c %n Clones are not welcome in %c $+ , tempbanned!
        popdll.disp popup
      }
    }
  }
  elseif ($devent == menu) {
    if ($did == 20) {
      if ($remc(who)) { errdialog there is already another /who request going on. Please wait for it to finish. }
      else { .who $did(7).seltext }
    }
    elseif ($did == 18) { dialog -c $dname }
    elseif ($did == 21) { cscan.do }
  }
}
alias cscan.do {
  did -r clonescan 6
  did -i clonescan 6 1 cb root
  did -a clonescan 6 +be 1 1 0 0 0 Hostnames
  did -i clonescan 6 1 cb last
  var %m = $nnticks,%x = $did(clonescan,7).seltext,%s = $ialchan(*,%x,0),%c = 0,%v = $nick(%x,0)
  did -ra clonescan 14 %v
  if (%s != %v) {
    did -a clonescan 6 + 1 1 0 0 0 IAL for %x not filled!
    did -bra clonescan 9,11,13 n/a
    did -b clonescan 4,5,6,8,10,12,14,15
  }
  else {
    did -e clonescan 4,5,6,8,9,10,11,12,13,14,15
    _hmake clonescan
    while (%s) {
      hinc clonescan *@ $+ $gettok($ialchan(*,%x,%s),2-,64)
      dec %s
    }
    var %s = $hget(clonescan,0).item
    while (%s) {
      var %l = 1,%t = $hget(clonescan,%s).item,%h = $hget(clonescan,%t)
      if (%h > 1) {
        did -a clonescan 6 + 1 1 0 0 0 $+($gettok(%t,2-,64),	Host: $gettok(%t,2-,64),$cr,Users:) %h
        did -i clonescan 6 1 cb last
        while (%l <= %h) {
          var %ö = $ialchan(%t,%x,%l).nick,%g = $iif(%ö !isreg %x,$left($nick(%x,%ö).pnick,1)) $+ %ö
          did -a clonescan 6 + 1 1 0 0 0 $+(%g,	Nickname: $ialchan(%t,%x,%l).nick,$cr,Clone #: %l,/,%h,$cr,Address: $gettok($ialchan(%t,%x,%l),2-,33),$cr,Idle) time: $sduration($nick(%x,%ö).idle)
          inc %l
        }
        did -i clonescan 6 1 sort
        did -i clonescan 6 1 cb up
        inc %c $calc(%h -1)
      }
      dec %s
    }
    if (!%c) { did -a clonescan 6 + 1 1 0 0 0 No clones on %x found. }
    else { did -i clonescan 6 1 sort }
    did -ra clonescan 9 %c
    did -ra clonescan 11 $percent(%c,$nick(%x,0),0)
    did -ra clonescan 13 $round($calc(($nnticks - %m)/1000),2) $+ s
    hfree clonescan
  }
}
dialog away {
  title "Away system [/a]"
  size -1 -1 254 240
  option pixels
  icon script\pics\nntray.ico
  box "Away presets", 3, 4 0 246 128
  list 4, 12 16 184 102, sort size extsel vsbar
  button "&Add", 5, 200 18 40 24
  button "&Rem.", 50, 200 82 40 24, disable
  button "&Edit", 12, 200 50 40 24, disable
  box "Settings", 6, 4 134 246 72
  text "Reason", 7, 12 154 40 14
  edit "", 8, 66 150 176 22, autohs limit 100
  text "Nick", 9, 12 178 22 14
  edit "", 10, 66 174 146 22, autohs limit 30
  button "Set &away", 1, 4 212 80 24, ok
  button "Set &back", 11, 84 212 80 24, disable
  button "&Close", 2, 170 212 80 24, cancel
  button "&?", 17, 214 174 28 22
  menu "&File", 15
  item "Set &away", 24, 15
  item "Set &back", 25, 15
  item break, 23, 15
  item "&Options", 27, 15
  item break, 26, 15
  item "&Close", 19, 15
  menu "&Presets", 16
  item "&Add preset", 20, 16
  item break, 30, 16
  item "&Edit selected", 22, 16
  item break, 29, 16
  item "&Remove selected", 21, 16
  item "&Clear presets", 28, 16
}
raw 305:*:{
  var %t = You are no longer marked as being away $iif($awaytime,after $thmhl($sduration($v1).nosec)) $iif($awaymsg,as $thmhl($v1)) on $thmhl($curconserv) $+ .
  thmecho $asecho %t
  if ($window($away.logwin)) { thmecho $v1 %t }
  if ($dialog(away)) { did -b $v1 11,25 }
  unset %away.oldnick. $+ $curconserv
  haltdef
}
raw 306:*:{
  var %t = You have been marked as being away $iif($awaymsg,as $thmhl($v1)) on $thmhl($curconserv) $+ .
  thmecho $asecho %t
  if ($window($away.logwin)) { thmecho $v1 %t }
  inc %stat.away
  if ($dialog(away)) { did -e $v1 11,25 }
  haltdef
}
alias nick.def {
  var %n
  if (%nick.def. [ $+ [ $network ] ]) { %n = $v1 }
  elseif (%nick.def) { %n = $v1 }
  if ($isid) { return %n }
  else {
    if (%n) { nick $v1 }
    else { thmerror -a No default nick found. }
  }
}
alias nick.away {
  var %n
  if (%nick.away. [ $+ [ $network ] ]) { %n = $v1 }
  elseif (%nick.away) { %n = $v1 }
  if ($isid) { return %n }
  else {
    if (%n) { nick $v1 }
    else { thmerror -a No away nick found. }
  }
}
alias aw.chksel {
  if ($did(away,4).sel) {
    tokenize 32 $hget(awaypreset,$replace($did(away,4).seltext,$chr(32),_))
    did -ra away 10 $1
    did -ra away 8 $2-
    did -e away 1,6,7,8,9,10,12,50,21,22,24
  }
  else {
    did -r away 8,10
    did -b away 1,6,7,8,9,10,12,50,21,22,24
  }
}
on *:dialog:away:*:*:{
  if ($devent == init) {
    if ($away) { did -e $dname 11,25 }
    var %i = $hget(awaypreset,0).item
    while (%i) {
      did -a $dname 4 $replace($hget(awaypreset,%i).item,_,$chr(32))
      dec %i
    }
    if (!$did(4).lines) { did -b $dname 28 }
    else { did -c $dname 4 1 }
    aw.chksel
  }
  elseif ($devent == sclick) {
    if ($did == 1) {
      if ($anyconnection) { aw $replace($did(4).seltext,$chr(32),_) }
      else {
        errdialog you are not connected to any server!
        halt
      }
    }
    elseif ($did == 11) {
      if ($anyconnection) { back }
      else { errdialog you are not connected to any server! }
    }
    elseif ($did == 4) { aw.chksel }
    elseif ($did == 5) { awpreset.add }
    elseif ($did == 12) { awpreset.edit }
    elseif ($did == 50) { awpreset.remsel }
    elseif ($did == 17) { idialog You can use various identifiers for your away nickname:<me>: your current nick (example: <me>^away)<back>: your default nick<away>: your network-specific away nick }
  }
  elseif ($devent == menu) {
    if ($did == 27) {
      setup
      did -i settings 1 1 branch expand 3
      did -c settings 1 3
      setclk 2 3
    }
    elseif ($did == 22) { awpreset.edit }
    elseif ($did == 20) { awpreset.add }
    elseif ($did == 21) { awpreset.remsel }
    elseif ($did == 28) { awpreset.clear }
    elseif ($did == 19) { dialog -c $dname }
    elseif ($did == 24) { aw $replace($did(4).seltext,$chr(32),_) }
    elseif ($did == 25) { back }
  }
  elseif ($devent == dclick) && ($did == 4) { dialog -k $dname }
  elseif ($devent == edit) {
    if ($istok(8 10,$did,32)) {
      hadd awaypreset $replace($did(4).seltext,$chr(32),_) $iif($remove($did(10),$chr(32)),$v1,$iif(%nick.away,$v1,<me>)) $iif($strip($did(8)),$v1,gone)
      hsave -ob awaypreset script\tables\awaypreset.tbl
    }
  }
}
alias awpreset.clear {
  if ($ydialog(Do you really want to remove all away presets?)) {
    hdel -w awaypreset *
    did -r away 4,8,10
    did -b away 1,6,7,8,9,10,12,50,21,28,22,24
  }
}
alias awpreset.remsel {
  while ($did(away,4).sel) {
    hdel awaypreset $replace($did(away,4).seltext,$chr(32),_)
    did -d $dname 4 $did(away,4).sel
  }
  hsave -ob awaypreset script\tables\awaypreset.tbl
  did -r away 8,10
  did -b away 1,6,7,8,9,10,12,50,21,24
  if (!$did(away,4).lines) { did -b $dname 28 }
}
alias awpreset.add {
  var %r = $$eddialog(Enter a name for a new away preset!),%n = $replace(%r,$chr(32),_)
  if ($didwm(away,4,%r)) { errdialog an away preset with the name $qt(%r) already exists! }
  else {
    hadd awaypreset %n $iif(%nick.away,$v1,$me) %r
    hsave -ob awaypreset script\tables\awaypreset.tbl
    did -a away 4 %r
    did -e away 28
  }
}
alias awpreset.edit {
  var %r = $$eddialog(Enter a new name for the away preset $+(",$did(away,4).seltext,"!),$did(away,4).seltext),%n = $replace(%r,$chr(32),_),%d = $replace($did(away,4).seltext,$chr(32),_)
  if ($didwm(away,4,%r)) { errdialog an away preset with the name $qt(%r) already exists! }
  else {
    hadd awaypreset %n $hget(awaypreset,%d)
    hdel awaypreset %d
    hsave -ob awaypreset script\tables\awaypreset.tbl
    did -oc away 4 $did(away,4).sel %r
    did -e away 1,6,7,8,9,10,12,50,21,22,24
  }
}
dialog idleaway {
  title "Auto-away"
  size -1 -1 240 120
  option pixels
  icon script\pics\nntray.ico
  text "Warning:", 1, 6 6 46 16
  text "", 2, 54 6 180 54
  text "", 3, 54 64 126 16
  button "&Cancel away", 5, 156 92 80 24, cancel
  button "&Go away now", 4, 70 92 80 24, ok
  box "", 6, -2 78 244 8
}
on *:dialog:idleaway:*:*:{
  if ($devent == init) {
    did -a $dname 2 you have chosen to go auto-away after $calc(%auto.awaytime /60) minutes of idling. If you don't press cancel within the next 20 seconds, you will be set away.
    did -a $dname 3 20 seconds remaining...
    .timeridleaway 20 1 aw.idlinc
  }
  elseif ($devent == sclick) {
    if ($did == 4) { aw -i }
    elseif ($did == 5) { scon -at1 resetidle }
  }
  elseif ($devent == close) { .timeridleaway off }
}
alias checkidle {
  if ($dialog(idleaway)) { return }
  var %x = 0,%t = 0,%z = 1
  while ($scon(%z)) {
    scon %z
    if ($status == connected) {
      inc %t
      if ($idle < %auto.awaytime) || ($away) { return }
    }
    inc %z
  }
  scon -r
  if (%away.auto.warn) { nndlg -mo idleaway }
  else { aw -i }
}
alias aw.idlinc {
  if ($dialog(idleaway)) {
    var %x = $calc($wd($did(idleaway,3),1) -1)
    if (!%x) {
      dialog -x idleaway
      aw -i
    }
    else { did -ra idleaway 3 %x seconds remaining... }
  }
  else { .timeridleaway off }
}
alias sa { .aw $1- }
alias saw { .aw $1- }
alias saway { .aw $1- }
alias a { aw $1- }
alias aw {
  if (!$1-) { nndlg -m away }
  else {
    var %i = $scid(0),%n,%r,%t
    while (%i) {
      scid $scon(%i)
      if ($status == connected) {
        if ($1 == -n) { var %n = $2,%t = $3- }
        else { var %n = $nick.away,%t = $1- }
        if ($hget(awaypreset,%t)) { var %n = $wd($v1,1),%t = $wd($v1,2-) }
        if ($1 == -i) { var %t = auto-away after $sduration(%auto.awaytime).nosec idle,%r = is now %t }
        elseif (%t) { %r = is now away: %t }
        else { %r = is now away! }
        if (!%away.oldnick. [ $+ [ $curconserv ] ]) { set %away.oldnick. $+ $curconserv $me }
        !away %t $iif(%away.atime,$nbr(since $asctime(HH:nn/mmmm ddoo)))
        if ($show) {
          %n = $replace(%n,<me>,$me,<back>,$nick.def,<away>,$nick.away)
          if (%n) && (%n !=== $me) { nick %n }
          if ($1 != -i) || (!%away.auto.nomsg) { aw.domsgs %r }
        }
        else { %n = $me }
      }
      dec %i
    }
    set %away.status $ctime $iif($1 == -i,i,-) %n %t
  }
}
on *:exit: { if (%away.status) { back } }
alias sre { .back }
alias sback { .back }
alias re { back }
alias back {
  scon -at1 resetidle
  tokenize 32 %away.status
  var %i = $scid(0),%t = $iif($calc($ctime - $1) isnum 0-31536000,$v1,0),%r
  if ($4-) { %r = is back from: $4- $iif(%t,$nbr(been away for $sduration(%t).nosec)) }
  elseif ($1) { %r = is back! $iif(%t,$nbr(been away for $sduration(%t).nosec)) }
  else { %r = is back! }
  while (%i) {
    scid $scon(%i)
    if ($away) {
      var %t = 1,%n
      !away
      if ($show) {
        if (%away.useold) && (%away.oldnick. [ $+ [ $curconserv ] ]) { %n = $v1 }
        else { %n = $nick.def }
        if (%n) && (%n !=== $me) { nick %n }
        if ($2 != i) || (!%away.auto.nomsg) { aw.domsgs %r }
      }
      else { %n = $me }
    }
    dec %i
  }
  if (!%t) { thmerror -a You are not away! }
  if (%awaypager.enabled) {
    if ($isfile(script\txt\awpages.txt)) {
      .fopen pager script\txt\awpages.txt
      while (!$feof) {
        if (0 * iswm $fread(pager)) {
          thmecho -a You have unread away pages! Type $thmhl(/pager) to look at them now.
          break
        }
      }
      .fclose pager
    }
  }
  unset %away.status %away.oldnick.*
}
alias aw.domsgs {
  .timerawmsg.*.* off
  if (!%away.nomsg) {
    if (%away.pubmsg == 1) { if ($active != Status Window) && (@* !iswm $active) && ($cid == $activecid) && (!$istok(%away.ad.excl,$active,44)) { describe $active $1- } }
    else {
      if (%away.ignorechans) && (%away.ad.excl) {
        var %c = $chan(0),%q = $query(0),%f = 0
        while (%c) {
          if (!$istok(%away.ad.excl,$chan(%c),44)) && ($me ison $chan(%c)) {
            $+(.timerawmsg.,$cid,.,$chan(%c)) 1 %f if ($chan( $+ %c $+ )) $chr(123) describe $!v1 $1- $chr(125)
            inc %f 2
          }
          dec %c
        }
        if (%away.ad.queries) {
          while (%q) {
            if (!$istok(%away.ad.excl,$query(%q),44)) {
              $+(.timerawmsg.,$cid,.,$query(%q)) 1 %f if ($query( $+ %q $+ )) $chr(123) describe $!v1 $1- $chr(125)
              inc %f 2
            }
            dec %q
          }
        }
      }
      else {
        if ($chan(0)) { ame $1- }
        if (%away.ad.queries) && ($query(0)) { qme $1- }
      }
    }
  }
}
alias aw.chkhl {
  if (%away.remind) && ($away) && (!%aw.reminded. [ $+ [ $cid ] $+ ] . [ $+ [ $nick ] ]) && (!%aw.remindflood) {
    set -u3600 $+(%,aw.reminded.,$cid,.,$nick) 1
    set -u4 %aw.remindflood 1
    .notice $nick I have been away for $duration($awaytime) $+ : $awaymsg (one-time response to highlight)
  }
}
menu @awaylog[*] {
  $style(2) $+([,$shorten(15,$active),]):return
  -
  Clear:clear $active
  Close:close -@ $active
}
alias away.chklog {
  if ($away) && (%away.log) && ((($prop == event) && (%away.log.events)) || (((%away.hllog) && ($isachl($1-))) || ((%away.log.trigger) && ($regex(awlog,$1-,%away.log.trigger))))) {
    if (!$window($away.logwin)) {
      window -nk0 $away.logwin
      thmecho $away.logwin Away log window opened on $thmhl($longtime)
      thmecho $away.logwin You are currently marked away as $thmhl($awaymsg)
      echo $away.logwin 
    }
    return 1
  }
}
alias away.logwin { return $+(@Awaylog[,$cid,]) }
ctcp *:page:?:{
  if (%awaypager.enabled) {
    if ($away) {
      write -il1 script\txt\awpages.txt 0 $ctime $iif($ial($nick),$v1,$nick) $strip($2-)
      if (!%pagerflood. [ $+ [ $cid ] ]) { .notice $nick Thanks for your page! }
    }
    elseif (!%pagerflood. [ $+ [ $cid ] ]) { .notice $nick I am not away... }
    set -u4 %pagerflood. $+ $cid 1
  }
}
alias pager { nndlg -m awaypager }
dialog awaypager {
  title "Away pager [/pager]"
  size -1 -1 396 224
  option pixels
  icon script\pics\nntray.ico
  list 1, 12 18 138 164, size
  box "Choose page", 2, 4 2 154 188
  box "Page info", 3, 166 2 226 188
  text "From", 5, 176 22 28 16
  edit "Select a page!", 8, 214 18 170 22, read autohs
  text "Rcvd.", 9, 176 44 30 16
  edit "n/a", 10, 214 40 170 22, read autohs
  text "At", 12, 176 66 18 16
  edit "n/a", 13, 214 62 170 22, read autohs
  edit "n/a", 15, 214 84 170 98, read multi return vsbar
  text "Text", 16, 176 88 28 16
  button "&Close", 4, 312 196 80 24, ok
  menu "&File", 14
  item "&Close", 18, 14
  menu "&Pager", 17
  item "&Refresh pages", 19, 17
  item break, 20, 17
  item "R&emove selected pages", 21, 17
  item "&Clear pages", 22, 17
}
on *:dialog:awaypager:*:*:{
  if ($devent == init) {
    mdx SetControlMDX $dname 1 TreeView nohscroll haslines hasbuttons showsel > script\dlls\views.mdx
    aw.loadpages
  }
  elseif ($devent == sclick) {
    if ($did == 1) {
      tokenize 32 $did($did,1)
      if (slclick select * * * * iswm $1-) {
        did -i $dname 1 1 cb root $4-5
        var %t = $did($did,$6)
        did -i $dname 1 1 replaceitem $6 $puttok($puttok(%t,+s,1,32),Read,6,9)
        set %away.curpage $mid($gettok($gettok(%t,3,9),1,13),2)
        tokenize 32 $read(script\txt\awpages.txt,n,%away.curpage)
        did -ra $dname 8 $3
        did -ra $dname 10 $asctime($2,dddd $+ $chr(44) dd/mm/yyyy)
        did -ra $dname 13 $asctime($2,HH:nn:ss)
        did -ra $dname 15 $4-
        did -c $dname 8,10,13,15 1
        if (!$1) { write -l $+ %away.curpage script\txt\awpages.txt $puttok($1-,1,1,32) }
        did -e $dname 21
      }
      elseif (slclick select * * iswm $1-) {
        unset %away.curpage
        did -b $dname 21
        did -ra $dname 8 Select a page!
        did -ra $dname 10,13,15 n/a
      }
    }
  }
  elseif ($devent == menu) {
    if ($did == 19) { aw.loadpages }
    elseif ($did == 22) {
      if ($ydialog(Do you really want to remove all away pages?)) {
        write -c script\txt\awpages.txt
        aw.loadpages
      }
    }
    elseif ($did == 21) {
      write -dl $+ %away.curpage script\txt\awpages.txt
      aw.loadpages
    }
    elseif ($did == 18) { dialog -c $dname }
  }
  elseif ($devent == close) { unset %away.curpage }
}
alias aw.loadpages {
  unset %away.curpage
  did -b awaypager 21
  var %d,%t,%a,%l = 1,%z
  did -r awaypager 1
  did -i awaypager 1 1 cb root
  did -a awaypager 1 +eb 1 1 0 0 0 Pages
  did -i awaypager 1 1 cb last
  if ($isfile(script\txt\awpages.txt)) {
    .fopen pages script\txt\awpages.txt
    while (!$feof) {
      tokenize 32 $fread(pages)
      if ($regex($1-,/^0|1 \d+ .+ .+$/)) {
        %t = $asctime($2,dd/mm/yyyy)
        if (%d != %t) {
          if (%a) { did -i awaypager 1 1 cb up }
          %z = 1
          did -a awaypager 1 +e 1 1 0 0 0 %t
          did -i awaypager 1 1 cb last
        }
        var %d = %t,%a = 1
        did -a awaypager 1 $iif($1,+,+b) 1 1 0 0 0 $+($gettok($3,1,33),	Page:	#,%l,$crlf,From:	,$3,$crlf,Rcvd:	,$asctime($2,dd/mm/yyyy HH:nn:ss),$crlf,Status:	,$iif($1,Read,Unread))
      }
      inc %l
    }
    .fclose pages
  }
  if (!%z) {
    did -b awaypager 22
    did -a awaypager 1 + 1 1 0 0 0 No pages received.
  }
  did -ra awaypager 8 Select a page!
  did -ra awaypager 10,13,15 n/a
}
alias bkacs {
  var %b = 0,%i = $chan(0)
  while (%i) {
    var %cc = $ccontrol($chan(%i)),%k = $nick($chan(%i),0)
    while (%k) {
      if (%cc) && ($nick($chan(%i),%k) != $me) && ($hfind(black,$address($nick($chan(%i),%k),5),1,W)) {
        .timer 1 %b black.punish $chan(%i) $nick($chan(%i),%k) $v1
        inc %b
      }
      dec %k
    }
    dec %i
  }
}
alias black.kick.all {
  var %i = 1
  while (%i <= $nick($1,0)) {
    if ($nick($1,%i) != $me) && ($hfind(black,$address($nick($1,%i),5),1,W)) { .timer 1 %i black.punish $1 $nick($1,%i) $v1 }
    inc %i
  }
}
alias black.kick { if ($2 != $me) && ($hfind(black,$address($2,5),1,W)) { black.punish $1-2 $v1 } }
alias black.punish {
  if ($2 ison $1) {
    var %r = $hget(black,$3)
    .raw mode $1 -o+b $+($2-3,$crlf,kick $1-2 :,$iif(%r && %r != n/a,%r $+ $chr(44) blacklisted,Blacklisted)) $kc
    inc %black.kicked
  }
}
alias black.edit {
  tokenize 9 $did(black,5).seltext
  set %black.edit $wd($1,6-) $wd($2,5-)
  noop $dialog(black.add,black.add,-4)
  if (%black.addy) && (%black.comm) {
    hdel black $wd($1,6-)
    hadd black %black.addy %black.comm
    did -oc $dname 5 $did(5).sel 0 + 0 0 0 %black.addy $+ 	+ 0 0 0 %black.comm
    hsave -ob black script\tables\black.tbl
    scon -at1 bkacs
  }
  unset %black.comm %black.addy
}
dialog black {
  title "Blacklist [/black]"
  size -1 -1 320 200
  option pixels
  icon script\pics\nntray.ico
  list 5, 2 2 316 166, size extsel
  button "&Ok", 3, 236 172 80 24, ok
  menu "&File", 8
  item "&Close", 11, 8
  menu "&Edit blacklist", 9
  item "&Add entry", 12, 9
  item break, 13, 9
  item "&Edit entry", 14, 9
  item break, 15, 9
  item "&Remove entry", 16, 9
  item "&Clear list", 17, 9
  menu "&Information", 10
  item "&Show blacklist info", 18, 10
}
dialog black.add {
  title "Edit blacklist"
  size -1 -1 234 90
  option pixels
  icon script\pics\nntray.ico
  text "Address", 1, 6 8 60 16
  text "Comment", 2, 6 30 60 16
  edit "", 3, 70 4 160 22, autohs limit 100
  edit "", 4, 70 26 160 22, autohs limit 50
  box "", 5, -10 48 250 8
  button "&Cancel", 7, 66 62 80 24, cancel
  button "&Ok", 6, 150 62 80 24
}
alias black.loadlist {
  did -r black 5
  var %i = $hget(black,0).item
  if (!%i) { did -b black 17 }
  while (%i) {
    did -a black 5 0 + 0 0 0 $hget(black,%i).item $+ 	+ 0 0 0 $hget(black,%i).data
    dec %i
  }
  did -b black 14,16
}
on *:dialog:black:*:*:{
  if ($devent == init) {
    mdx SetControlMDX $dname 5 ListView report showsel rowselect > script\dlls\views.mdx
    did -i $dname 5 1 headerdims 160:1 120:2
    did -i $dname 5 1 headertext + 0 Mask	+ 0 Comment
    black.loadlist
    if (!%ialupdate) { idialog Warning: the feature that gets all user addresses when you join a channel is currently disabled. Only this feature ensures that all blacklisted users will be kicked after you join/get opped on a channel. If you want to enable it enter /setup and go to "Miscellaneous", "Part II". }
  }
  elseif ($devent == sclick) {
    if ($did == 5) {
      sortmdx $dname $did
      did $iif($did($did).sel,-e,-b) $dname 14,16
      if (rclick * iswm $did($did,1)) {
        popdll.new popup
        popdll.add popup + 0 0 &Add entry $cr black.add
        popdll.add popup
        popdll.add popup $iif(!$did($did).sel,+d,+) 0 0 &Edit entry $cr black.edit
        popdll.add popup
        popdll.add popup $iif(!$did($did).sel,+d,+) 0 0 &Remove entry $cr black.remsel
        popdll.add popup $iif($did($did).lines == 1,+d,+) 0 0 &Clear list $cr black.clear
        popdll.disp popup
      }
    }
  }
  elseif ($devent == menu) {
    if ($did == 17) { black.clear }
    elseif ($did == 18) { idialog Blacklist entries: $hget(black,0).item $+ Blacklist kicks: %black.kicked }
    elseif ($did == 14) { black.edit }
    elseif ($did == 16) { black.remsel }
    elseif ($did == 12) { black.add }
    elseif ($did == 11) { dialog -c $dname }
  }
  elseif ($devent == dclick) && ($did == 5) { black.edit }
}
alias black { nndlg -m black }
alias black.clear {
  if ($ydialog(Do you really want to clear the blacklist?)) {
    did -r black 5
    hdel -w black *
    hsave -ob black script\tables\black.tbl
    did -b black 14,16,17
  }
}
alias black.add {
  noop $dialog(black.add,black.add,-4)
  if (%black.addy) && (%black.comm) {
    if (%black.addy == *!*@*) { errdialog please be more specific. You can't blacklist everyone! }
    elseif (%black.addy iswm $address($me,5)) { errdialog you cannot add yourself to the list! }
    else {
      hadd black %black.addy %black.comm
      hsave -ob black script\tables\black.tbl
      scon -at1 bkacs
      if ($dialog(black)) {
        did -a black 5 0 + 0 0 0 %black.addy $+ 	+ 0 0 0 %black.comm
        did -e black 17
      }
      else { idialog %black.addy has been added to the blacklist. }
    }
    unset %black.addy %black.comm
  }
}
alias black.remsel {
  while ($did(black,5).sel) {
    hdel black $cell(black,5,1)
    did -d black 5 $did(black,5).sel
  }
  did -b black 14,16
  if ($did(black,5).lines == 1) { did -b black 17 }
  hsave -ob black script\tables\black.tbl
  if (!$did(black,5).lines) { did -b black 6 }
}
on *:dialog:black.add:*:*:{
  if ($devent == init) {
    unset %black.addy %black.comm
    if (%black.edit) {
      tokenize 32 $v1
      did -a $dname 3 $1
      did -a $dname 4 $2-
      unset %black.edit
    }
  }
  elseif ($devent == sclick) {
    if ($did == 6) {
      if (!$did(3)) { errdialog you did not enter an address! }
      else {
        set %black.addy $c.add($did(3))
        set %black.comm $iif($did(4),$did(4),n/a)
        dialog -c $dname
      }
    }
  }
}
alias black.remuser {
  if ($1) {
    var %x = 0
    while ($hfind(black,$1,1,Ww)) {
      hdel black $v1
      inc %x
    }
    if ($dialog(black)) { black.loadlist }
    idialog %x user(s) removed from the blacklist.
  }
  else { errdialog insufficient parameters. }
}
alias black.adduser {
  set %black.edit $1-
  black.add
}
raw 315:*:{ if ($ccontrol($2)) { black.kick.all $2 } }
on *:op:#:{ if ($opnick == $me) { black.kick.all $chan } }
on *:help:#:{ if ($hnick == $me) { black.kick.all $chan } }