; shroudIRC2
; © 2005 Gunnar Beutner
; #shroud @ QuakeNet
;
; auto-generated file created 01.01.2005 at 22:17:34
; from 51 source files using SIConcat - DO NOT EDIT!

on ^*:action:*:*:{
  if ($filtermsg($1-)) { haltdef }
  if ($chan && $hfind(chanhide,$chan,1) == $null) {
    hadd -m chanactivity $+ $cid $chan $ctime
    window -w $chan
  }
}
on *:text:*:*:{
  if ($($decode,0) isin $1-) {
    var %c = $av_decode($1-)
    if (%c != $1-) { kte_echo $iif($chan, $chan, $nick) Auto-Decode: %c }
  }
  if ($chan && $hfind(chanhide,$chan,1) == $null) {
    hadd -m chanactivity $+ $cid $chan $ctime
    window -w $chan
  }
}
on ^*:text:*:*:{
  if ($chan != $null) {
    var %msg = $1-
    if ($1 == [b] && $hget(bfchans,$chan) && $2 != $null) {
      haltdef
      var %msg = $bnext($bfdll(Decrypt,$hget(bfchans,$chan) $2-))
      var %xsn = $xsnsignature(%msg)
      if (%xsn != $null) { var %msg = $bnext(%msg) }
      if (%xsn != $null && %xsn != $nick) {
        if ($shroudget(bhideforged) != on) { echo -lt $chan [b, forged] $+(<,$nick($chan,$nick).pnick,>) %msg }
      }
      else { echo -mlbfti2 $chan [b] $+(<,$nick($chan,$nick).pnick,>) %msg }
      statsinc msgchan
      statsinc bfmsgchan
      statsinc wordchan $numtok(%msg, 32)
      if ($islame(%msg)) { statsinc lamechan }
    }
    else {
      statsinc msgchan
      statsinc wordchan $numtok($1-, 32)
      if ($islame($1-)) { statsinc lamechan }
    }
    if (!$appactive && $shroudget(balloon) == on && $me isin %msg) {
      traydll Balloon 1 3 > Highlight $+($chr(40),$nick,$chr(41)) > $iif($len(%msg) > 250, $left($strip(%msg), 250) $+ ..., $strip(%msg))
    }
    if (%msg == $shroudget(fstrigger) && $shroudget(fsenabled) == on) { fserve $nick 1 $shortfn($shroudget(fsdir)) }
    if ($chan == %vote_channel) {
      if (((%msg == %vote_a1) || (%msg == %vote_a2) || (%msg == %vote_a3) || (%msg == %vote_a4) || (%msg == %vote_a5)) && (%vote_runs == on)) {
        if ($iif($hfind(vote, $address($nick,1)) == $null, $false, $true)) { notice $nick $trans(OneVote) | unset %vote_no | goto votexz }
        hadd -m vote $address($nick,1)
        inc %vote_ges_num
        if (%msg == %vote_a1) { inc %vote_a1_num | notice $nick $trans(VoteAccepted) | goto votexz }
        if (%msg == %vote_a2) { inc %vote_a2_num | notice $nick $trans(VoteAccepted) | goto votexz }
        if (%msg == %vote_a3) { inc %vote_a3_num | notice $nick $trans(VoteAccepted) | goto votexz }
        if (%msg == %vote_a4) { inc %vote_a4_num | notice $nick $trans(VoteAccepted) | goto votexz }
        if (%msg == %vote_a5) { inc %vote_a5_num | notice $nick $trans(VoteAccepted) | goto votexz }
      }
      :votexz
    }
    if (%msg == [ [ $shroudget(smp3trigger) ] ]) {
      var %smp3file $smp3raw(TRACKFILENAME)
      if ($shroudget(smp3triggeract) == on) {
        if (http* iswm %smp3file) {
          notice $nick [Radio-URL: %smp3file $+ ]
        }
        if ($shroudget(smp3trigger) != $chr(42) && $shroudget(smp3trigger) != $chr(63) && $shroudget(smp3trigger) != $null) {
          dcc send -c $nick %smp3file
        }
      }
      else {
        notice $nick [lock: $shroudget(smp3lockmsg) $+ ]
      }
    }
    if (%msg == ? $+ $right( [ [ $shroudget(smp3trigger) ] ] ,-1) && $shroudget(smp3infotrigact) == on && $hget(temp, smp3infomutex) == $null) {
      if (($shroudget(smp3info) != wl && $hget(smp3info, $target) == $null) || ($shroudget(smp3info) == wl && $hget(smp3info, $target) != $null)) {
        hadd -z temp smp3infomutex 30
        xasync smp3 $target
      }
    }
    addr.setlast $address($nick, 2) $nick
    if ($filtermsg($1-)) { haltdef }
  }
  else {
    if ($nick == -psyBNC) {
      if (Wrong Password.* iswm $1-) {
        clear -s
        echo $color(info) -s .. Connection aborted: Wrong psyBNC password. Please fix this before re-connecting.
        disconnect
      }
      if (You have Messages.* iswm $1- || Du hast Nachrichten.* iswm $1- || Hai dei messaggi.* iswm $1-) {
        playprivatelog
        return
      }
      if (Starting playing Log* iswm $1- || Starte Wiedergabe des Logs* iswm $1- || Inizio play del Log* iswm $1-) {
        window -a @psylog
        window -h -psyBNC
        set %psylog 1
        return
      }
      if (Use ERASEPRIVATELOG to kill the log* iswm $1- || Verwende ERASEPRIVATELOG, um das Log zu loeschen* iswm $1- || Usa ERASEPRIVATELOG per eliminare il log* iswm $1-) {
        eraseprivatelog
        unset %psylog
        return
      }
      if ($window(@psylog) && %psylog == 1) {
        echo -mi2 @psylog $1-
        haltdef
        return
      }
      if ($active != -psyBNC && $shroudget(psyconv) == on) {
        echo $color(notice) -a --psyBNC- $1-
        window -h -psyBNC
      }
      else {
        window -w -psyBNC
      }
    }
    if ($1 == [b] && $hget(bfchans,$nick) != $null && $2 != $null) {
      var %msg = $bnext($bfdll(Decrypt,$hget(bfchans,$nick) $2-))
      var %xsn = $xsnsignature(%msg)
      if (%xsn != $null) { var %msg = $bnext(%msg) }
      if (%xsn != $null && %xsn != $nick) {
        if ($shroudget(bhideforged) != on) { echo -lt $nick [b, forged] $+(<,$nick,>) %msg) }
      }
      else { echo -mlbfti2 $nick [b] $+(<,$nick,>) %msg }
      statsinc msgqry
      statsinc bfmsgqry
      statsinc wordqry $numtok(%msg, 32)
      if ($islame(%msg)) { statsinc lameqry }
      if (!$appactive && $shroudget(balloon) == on) {
        traydll Balloon 1 3 > Query $+($chr(40),$nick,$chr(41)) > $strip($iif($len(%msg) > 250, $left(%msg, 250) $+ ..., %msg))
      }
      haltdef
    }
    else {
      statsinc msgqry
      statsinc wordqry $numtok($1-, 32)
      if ($islame($1-)) { statsinc lameqry }
      if (!$appactive && $shroudget(balloon) == on) {
        traydll Balloon 1 3 > Query $+($chr(40),$nick,$chr(41)) > $strip($iif($len($1-) > 250, $left($1-, 250) $+ ..., $1-))
      }
    }
  }
}
on ^*:chat:*:{
  if ($1 == [b] && $hget(bfchans,$nick) != $null && $2 != $null) {
    var %msg = $bnext($bfdll(Decrypt,$hget(bfchans,$nick) $2-))
    var %xsn = $xsnsignature(%msg)
    if (%xsn != $null) { var %msg = $bnext(%msg) }
    if (%xsn != $null && %xsn != $nick) {
      if ($shroudget(bhideforged) != on) { echo -lt =$nick [b, forged] $+(<,$nick,>) %msg }
    }
    else { echo -mlbfti2 =$nick [b] $+(<,$nick,>) %msg }
    statsinc bfmsgqry
    statsinc wordqry $numtok(%msg, 32)
    if (!$appactive && $shroudget(balloon) == on) {
      traydll Balloon 1 3 > Query $+($chr(40),$nick,$chr(41)) > $strip($iif($len(%msg) > 250, $left(%msg, 250) $+ ..., %msg))
    }
    haltdef
  }
  else {
    statsinc msgqry
    statsinc wordqry $numtok($1-, 32)
    if (!$appactive && $shroudget(balloon) == on) {
      traydll Balloon 1 3 > Query $+($chr(40),$nick,$chr(41)) > $strip($iif($len($1-) > 250, $left($1-, 250) $+ ..., $1-))
    }
  }
}
ctcp ^*:*:*:{
  statsinc ctcp
  if ($1 == FINGER) {
    ctcpreply $nick FINGER $me (coma@) Idle $duration($idle) (shroudIRC $shroudget(version) $+ )
    haltdef
  }
  elseif ($1 == LAG) {
    if ($nick == $me && %act) {
      haltdef
      var %msg = 4,1lag0[ $+ $calc(($ticks - $2) / 1000) $+ sec $+ ]
      msg %act $statsstripx(%act, %msg)
      unset %act
    }
  }
  elseif ($1 == VERSION) {
    ctcpreply $nick VERSION shroudIRC $shroudget(version) (Release: $shroudget(release) $+ )
  }
}
raw *:*:{
  statsinc raw
  if ($hget(hideevents)) {
    if ($hfind(hideevents, $numeric *, 1, w).data) {
      set %trighide 1
    }
    if (%trighide) {
      haltdef
    }
    if ($hfind(hideevents, * $numeric, 1, w).data) {
      unset %trighide
      hdel hideevents $ifmatch
    }
  }
  if ($numeric == 302) {
    if (!$2) { haltdef }
    if (%doauth != 1 && %xdoauth != 1) { return }
    if ($right($server, 13) == .quakenet.org) {
      if ($2- == Q*=+TheQBot@CServe.quakenet.org) {
        if ($shroudget(qsetx) == on && $shroudget(qsetr) == on) {
          mode $me +xR
        }
        else {
          if ($shroudget(qsetx) == on) { mode $me +x }
          if ($shroudget(qsetr) == on) { mode $me +R }
        }
        var %qnick = $siqgetnick
        if (%qnick != $null) {
          if ($shroudget(qaskpw) == on) {
            xasync quserauth %qnick
          }
          if ($siispwset && $shroudget(qaskpw) != on) {
            if ($shroudget(qchallenge) == on) {
              .msg q@cserve.quakenet.org challenge
              .timerauth $+ $cid 1 10 doperformc
            }
            elseif ($shroudget(qask) != on) {
              siqauth
              .timerauth $+ $cid 1 10 doperformc
            }
            else {
              xasync quseraskauth
            }
          }
        }
        else { doperformc }
        unset %doauth
        haltdef
      }
      else {
        if ($2- != $null) {
          yecho This doesn't seem to be our Q: $2-
        }
        doperformc
      }
    }
    if ($right($server, 13) == .undernet.org) {
      if ($2- == X=+cservice@undernet.org && $right($server,13) == .undernet.org) {
        if ($shroudget(xsetx) == on) {
          mode $me +x
        }
        var %xnick = $sixgetnick
        if (%xnick != $null) {
          if ($shroudget(xaskpw) == on) {
            xasync xuserauth %xnick
          }
          if ($sixispwset && $shroudget(xaskpw) != on) {
            if ($shroudget(xask) != on) {
              sixauth
            }
            else {
              xasync xuseraskauth
            }
          }
        }
        else { doperformc }
        unset %xdoauth
        haltdef
      }
      else {
        unset %xdoauth
        if ($2- != $null) {
          yecho This doesn't seem to be our X: $2-
        }
        doperformc
      }
    }
  }
  elseif ($numeric == 311) {
    if ($2 == $me) {
      set %qnotauthed 1
      set %xnotauthed 1
    }
  }
  elseif ($numeric == 318) {
    if ($hget(intwhois, $cid $+ $2) != $null) {
      haltdef
      hdel intwhois $cid $+ $2
    }
    if ($hget(wcmd, $cid $+ $2) == $null) { return }
    if ($hget(qauthex, $cid $+ $2) == $null) {
      var %auth = !noauth
    }
    else {
      var %auth = $hget(qauthex, $cid $+ $2)
    }
    var %xcmd = $hget(wcmd, $cid $+ $2)
    var %xparm = $hget(wparm, $cid $+ $2)
    hdel wcmd $cid $+ $2
    hdel wparm $cid $+ $2
    . %xcmd %auth $ial($2) $ial($2, 5) %xparm
    haltdef
  }
  elseif ($numeric == 305) {
    statecheck
  }
  elseif ($numeric == 306) {
    statecheck
  }
  elseif ($numeric == 315) {
    if ($hget(intwho, $cid $+ $gettok($2, 1, 44)) > 0) {
      haltdef 
      hdec intwho $cid $+ $2
    }
  }
  elseif ($numeric == 324) {
    haltdef
  }
  elseif ($numeric == 329) {
    haltdef
  }
  elseif ($numeric == 330) {
    hadd -m qauthex $cid $+ $2 $3
    if ($2 == $me) {
      set %qnotauthed 0
      set %xnotauthed 0
      hadd -m qauths $cid $3
    }
  }
  elseif ($numeric == 352) {
    if ($hget(intwho, $cid $+ $2) > 0) {
      calldispwho $2-
      haltdef
    }
  }
  elseif ($numeric == 354) {
    if ($2 == 230) {
      if ($hget(intwho, $cid $+ $3) > 0) { haltdef }
      if ($4 != 0) { hadd qauths $cid $4 }
      else {
        if (%wantauth == 1 && $network == QuakeNet) {
          set %doauth 1
          userhost Q
        }
        if (%xwantauth == 1 && $network == UnderNet) {
          set %xdoauth 1
          userhost X
        }
        unset %wantauth
        unset %xwantauth
      }
      if (%cldelayed) {
        if ($hget(qauths, $cid) != $null) {
          sichanlev %cldelayedchan
        }
        else {
          xecho could not determine your account-name .. aborting
          unset %cldelayed*
        }
      }
    }
    if ($2 == 231) {
      if ($hget(intwho, $cid $+ $5) > 0) { haltdef }
      if ($hget(wcmd, $cid $+ $5) == $null) { return }
      var %xcmd = $hget(wcmd, $cid $+ $5)
      var %xparm = $hget(wparm, $cid $+ $5)
      hdel wcmd $cid $+ $5
      hdel wparm $cid $+ $5
      . %xcmd $iif($6 == 0, !noauth, $6) $5 $+ ! $+ $3 $+ @ $+ $4 %xparm
    }
  }
  elseif ($numeric == 366) {
    if ($me isop $2 && $nick($2, 0) == 1) { pushmode $2 +n | pushmode $2 +t }
  }
  elseif ($numeric == 367) {
    if ($hget(temp, hidebans $+ $cid) > 0) { haltdef }
  }
  elseif ($numeric == 368) {
    if ($hget(temp, hidebans $+ $cid) > 0) {
      haltdef
      hdec temp hidebans $+ $cid
    }
    checkbans $2
  }
  elseif ($numeric == 471) {
    var %lflag $hget(lflagtab,$2)
    var %qflag $hget(qflagtab,$2)
    if (* !isin %qflag && $hget(qauths, $cid)) {
      if (o isin %qflag || m isin %qflag || n isin %qflag) {
        ifnet .quakenet.org msg q invite $2
        if (!$atmodeallowed($2,i)) {
          ifnet .quakenet.org msg q clearchan $2
        }
        ifnet .quakenet.org timer 1 1 join $2
      }
    }
    if (* !isin %lflag  && $hget(qauths, $cid)) {
      if (o isin %lflag || m isin %lflag || n isin %lflag) {
        ifnet .quakenet.org msg l invite $2
        if (!$atmodeallowed($2,i)) {
          ifnet .quakenet.org msg l clearchan $2
        }
        ifnet .quakenet.org timer 1 1 join $2
      }
    }
  }
  elseif ($numeric == 433) {
    var %file = $hget(nickserv, $2 $+ / $+ $network)
    if (%file && $shroudget(autoghost) != off  && $hget(ghosts, $2) == $null) {
      sinsghost %file
      .timer 1 1 nick $2
      hadd -mu20 ghosts $2 $2
    }
  }
  elseif ($numeric == 473) {
    var %lflag $hget(lflagtab,$2)
    var %qflag $hget(qflagtab,$2)
    if (* !isin %qflag && $hget(qauths, $cid)) {
      if (o isin %qflag || m isin %qflag || n isin %qflag) {
        ifnet .quakenet.org msg q invite $2
        if (!$atmodeallowed($2,i)) {
          ifnet .quakenet.org msg q clearchan $2
          if (m isin %qflag || n isin %qflag) { ifnet .quakenet.org msg q deopall $2 }
        }
        ifnet .quakenet.org timer 1 1 join $2
      }
    }
    if (* !isin %lflag && $hget(qauths, $cid)) {
      if (o isin %lflag || m isin %lflag || n isin %lflag) {
        ifnet .quakenet.org msg l invite $2
        if (!$atmodeallowed($2,i)) {
          ifnet .quakenet.org msg l clearchan $2
          if (m isin %lflag || n isin %lflag) { ifnet .quakenet.org msg l deopall $2 }
        }
        ifnet .quakenet.org timer 1 1 join $2
      }
    }
  }
  elseif ($numeric == 474) {
    var %lflag $hget(lflagtab,$2)
    var %qflag $hget(qflagtab,$2)
    if (* !isin %qflag && $hget(qauths, $cid)) {
      if (o isin %qflag || m isin %qflag || n isin %qflag) {
        ifnet .quakenet.org msg q unbanall $2
        if (m isin %qflag || n isin %qflag) { ifnet .quakenet.org msg q deopall $2 }
        ifnet .quakenet.org timer 1 1 join $2
      }
    }
    if (* !isin %lflag && $hget(qauths, $cid)) {
      if (o isin %lflag || m isin %lflag || n isin %lflag) {
        ifnet .quakenet.org msg l unbanall $2
        if (m isin %lflag || n isin %lflag) { ifnet .quakenet.org msg l deopall $2 }
        ifnet .quakenet.org timer 1 1 join $2
      }
    }
  }
  elseif ($numeric == 475) {
    var %lflag $hget(lflagtab,$2)
    var %qflag $hget(qflagtab,$2)
    if (* !isin %qflag && $hget(qauths, $cid)) {
      if (o isin %qflag || m isin %qflag || n isin %qflag) {
        ifnet .quakenet.org msg q invite $2
        if (!$atmodeallowed($2,k)) {
          ifnet .quakenet.org msg q clearchan $2
          if (m isin %qflag || n isin %qflag) { ifnet .quakenet.org msg q deopall $2 }
        }
        ifnet .quakenet.org timer 1 1 join $2
      }
    }
    if (* !isin %lflag && $hget(qauths, $cid)) {
      if (o isin %lflag || m isin %lflag || n isin %lflag) {
        ifnet .quakenet.org msg l invite $2
        if (!$atmodeallowed($2,k)) {
          ifnet .quakenet.org msg l clearchan $2
          if (m isin %lflag || n isin %lflag) { ifnet .quakenet.org msg l deopall $2 }
        }
        ifnet .quakenet.org timer 1 1 join $2
      }
    }
  }
  elseif ($numeric == 485) {
    haltdef
    echo $color(info) -t $3 * $+(-,$2,-) $4-
  }
  if ($istok(311 401 301 311 312 313 319 330 317 318 378 307 338 320, $numeric, 32)) {
    if ($hget(intwhois, $cid $+ $2) != $null) {
      haltdef
      if ($numeric == 318) {
        hdel intwhois $cid $+ $2 
      }
    }
  }
}
alias asyncjoinwork {
  var %chan = $hget(asyncjoins. $+ $cid, 1).item
  if (%chan == $null) { return }
  .timerjqueue 1 5 asyncjoinwork
  hdel asyncjoins. $+ $cid %chan
  hidebans
  mode %chan +b
}
alias asyncjoin {
  hadd -m asyncjoins. $+ $cid $$1
  if (!$timer(jqueue)) {
    if ($hget(asyncjoins. $+ $cid,0).item == 1) {
      .timerjqueue 1 2 asyncjoinwork
    }
    else {
      .timerjqueue 1 3 asyncjoinwork
    }
  }
}
on ^!*:join:#:{
  if (!$isnetsplitnet) { return  }
  if ($true) {
    var %f = $hfind(splitted. $+ $cid, $+($nick,!*), 1, w), %t = splitted. $+ $cid
    if (!%f) { var %f = $hfind(netsplit. $+ $cid, $+($nick,!*), 1, w), %t = netsplit. $+ $cid }
    if (!%f) { return }
    if ($remtok($hget(%t, %f), $chan, 32)) {
      hadd -mu3600 %t $fulladdress $ifmatch
    }
    else {
      hdel -mu3600 %t $fulladdress
    }
    var %d = 1
    while (%d <= $comchan($nick, 0)) { 
      var %a = $addtok(%a, $comchan($nick, %d), 32)
      inc %d
    }
    if (splitted.* iswm %t) {
      hadd -m3600 netjoin. $+ $cid $nick %a
      .timershowjoins 1 3 showjoins
      .signal -n netburstone $chan $nick
      echo -st (signal) netburstone $chan $nick
    }
    else {
      hadd -mu10 temp shortsplit $addtok($hget(temp, shortsplit), $nick, 44)
      .timersplitwarn 1 3 yecho Warning: very short netsplit detected (took less than 3 seconds)! $&
        splitted nicks: $!replace($hget(temp, shortsplit), $!chr(44), $!+($chr(44),$chr(32)))
    }
    haltdef
  }
}
on ^*:rawmode:#:{
  if (!$isnetsplitnet || . !isin $nick) { return  }
  tokenize 32 $2-
  servopcheck $*
}
on *:join:#:{
  statsinc join
  if ($nick == $me) {
    asyncjoin $chan
    if ($hfind(chanhide,$chan,1) != $null) {
      .window -h $chan
    }
    hadd -m chanactivity $+ $cid $chan $ctime
  }
  else {
    var %i = 1
    var %cnt = $hget(blacklist,0).item
    while (%i <= %cnt) {
      if ($hget(blacklist, %i).item iswm $address($nick,-1) && $me isop $chan) {
        pushmode $chan +b $hget(blacklist, %i).item
        pushkick $chan $nick blacklisted $+ $iif($hget(blacklist, %i).data != $null,: $hget(blacklist, %i).data,$null)
      }
      inc %i
    }
    if ($hget(silast, $address($nick, 2)) != $null && $left($nick,1) != $) {
      .timer 1 5 addr.setlast $address($nick, 2)) $nick
    }
    else {
      addr.setlast $address($nick, 2)) $nick
    }
  }
  if ($ialchan($mask($fulladdress, 2), $chan, 0) > 15) {
    kte_echo $chan Warning: There are $ialchan($mask($fulladdress, 2), $chan, 0) clients which are connecting from $mask($fulladdress, 2)
    select $mask($fulladdress, 2)
  }
}
on *:rawmode:#:{
  if ($me isop $chan || $me ishop $chan) { modecheck $chan $1- }
}
on *:op:#:{
  if ($opnick == $me) {
    statsinc op
    if (!$chan($chan).ibl) {
      hidebans
      mode $chan +b
    }
    else {
      checkbans $chan
    }
    modecheck $chan
    checkblacklist
  }
}
on 1:help:#:{
  if ($hnick == $me) {
    statsinc halfop
    modecheck $chan 
  }
}
on *:deop:#:{
  if ($opnick == $me && $nick != $me) {
    statsinc deop
    recoverflags $chan
  }
}
on *:voice:#:{
  statsinc voice
}
on !*:devoice:#:{
  if ($vnick == $me) {
    statsinc devoice
    recoverflags $chan
  }
}
on *:dns:{
  var %n = $dns(0)
  echo $color(whois) -at Found %n address(es)
  while (%n > 0) {
    echo $color(whois) -at dns: $dns(%n).addr -> $dns(%n).ip
    dec %n
  }
  haltdef
}
on *:ban:#:{
  if ($me !isop $chan && $me !ishop $chan) { return }
  if ($banhit($banmask, $chan)) {
    kte.echo $chan Users affected by (+b $banmask $+ ): $ifmatch
  }
  if (($banmask iswm $address($me,-1) || ($mask2host($banmask) iswm $hget(qauths,$cid) $+ $iif($network == Undernet, .users.undernet.org, .users.quakenet.org) && $mask2ident($banmask) iswm $mask2ident($address($me,-1)) && $mask2nick($banmask) iswm $me)) && $shroudget(unbanself) == on) {
    if (!$atmodeallowed($network $+ / $+ $chan,f) && $nick != $me) {
      if (!$atmodeallowed($network $+ / $+ $chan, p)) {
        blacklist.add $address($nick, 3) $trans(ForbiddenModes, +b $banmask, $chan)
      }
      if (!$atmodeallowed($network $+ / $+ $chan, b)) {
        xbankick $chan $nick $true $trans(ForbiddenModes, +b $banmask, $chan)
      }
    }
    pushmode $chan -b $banmask
  }
}
alias withstar {
  if (* isin $hget($1, $2)) {
    hadd -m $1 $2 * $+ $3
  }
  else {
    hadd -m $1-
  }
}
on ^*:notice:*:*:{
  if ($nick == NickServ && (*nickname is registered and protected* iswm $1- || *Nickname ist registriert und geschützt* iswm $1-)) {
    if (!$hget(nickserv, $me $+ / $+ $network)) {
      return
    }
    sinsauth $hget(nickserv, $me $+ / $+ $network)
  }
  if ($nick == NickServ && *Password incorrect* iswm $1-) {
    if (!$hget(nickserv, $me $+ / $+ $network)) { return }
    .timer 1 1 remove $hget(nickserv, $me $+ / $+ $network)
    hdel nickserv $me $+ / $+ $network
    xecho password for $me $+ / $+ $network seems to be incorrect or you have changed the encryption key (removing from list of passwords)
  }
  if ($fulladdress == Welcome!psyBNC@lam3rz.de && $left($1, 6) == psyBNC) {
    hadd -m psybnc $cid $1
  }
  if ($nick == -psyBNC && Your IRC Client did not support a password.* iswm $1-) {
    psypw_help
  }
  if ($nick == AuthServ && $isauthserv) {
    if ($1- == I recognize you. || $1- == Incorrect password; please try again.) {
      doperformc
    }
  }
  if ($nick == X && $network == UnderNet) {
    if (*AUTHENTICATION SUCCESSFUL* iswm $1-) {
      doperformc
      checkauth $me xnull
    }
    if (*AUTHENTICATION FAILED* iswm $1-) {
      doperformc
    }
  }
  if ($network == QuakeNet) {
    if ($nick == L) {
      if (%lflags) {
        if ($mid($1,1,1) $+ a == #a) {
          var %flag = $2
          if (* isin $hget(backuplflagtab, $1)) {
            var %flag = * $+ %flag
          }
          if (* isin $hget(lflagtab, $1)) { var %flag = * $+ [ [ %flag ] ] }
          hadd -m lflagtab $1 %flag
        }
      }
      if (%qncl && $3- == $null && $2 != $null && $dialog(sichanlev)) {
        if ($1 == $hget(qauths, $cid)) { withstar lflagtab $did(sichanlev, 2).text $2 }
        if (!$window(@chanlev)) { window -h @chanlev }
        aline @chanlev $1-2
      }
      if ($1-4 == Sorry, you do not) {
        if ($dialog(sichanlev)) {
          did -b sichanlev 3
          did -b sichanlev 4
          did -b sichanlev 5
          did -b sichanlev 6
        }
        hdec temp lhide $+ $cid
        unset %qncl
      }
      if ($1-3 == End of list. || $1-3 == End of chanlev) {
        if (%qncl) {
          if (!$regex($hget(qflagtab, $did(sichanlev, 2).text), [m-n]) && !$regex($hget(lflagtab, $did(sichanlev, 2).text), [m-n])) {
            did -b sichanlev 4
            did -b sichanlev 5
            did -b sichanlev 6
          }
          did -e sichanlev 3
          sicl_addlistfiltered
        }
        if (%lflags) {
          hsave -oi lflagtab lqflags.hash lflags
          yecho L flags list updated
        }
        unset %qncl
        unset %lflags
        if ($hget(temp, lhide $+ $cid) > 0) {
          hdec temp lhide $+ $cid
          if ($dialog(sisettings)) { updlqflagslist sisettings }
          if ($hget(backuplflagtab)) { hfree backuplflagtab }
          if ($1-3 == End of list. || $1-3 == End of chanlev) { haltdef | return }
        }
      }
      if ($hget(temp, lhide $+ $cid) > 0) {
        haltdef | return
      }
    }
    if ($nick == Q) {
      if ($1 == CHALLENGE && $3 != $null && $4 == $null) { siqcauth $2-3 }
      if (*AUTH'd successfully* iswm $1-) {
        if ($calc(%authcounter % 10) == 0) { lqflags }
        inc %authcounter
        doperformc
        checkauth $me xnull
      }
      if (*Username or password incorrect, or you are already authed.* iswm $1-) {
        doperformc
      }
      if (%qflags) {
        if ($1 == Access && $2 == level && $4 == on && $5 == channel) {
          var %flag = $mid($3,2,$calc($len($3)-1))
          if (* isin $hget(backupqflagtab, $6)) { var %flag = * $+ %flag }
          if (* isin $hget(qflagtab, $6)) { var %flag = * $+ [ [ %flag ] ] }
          hadd -m qflagtab $6 %flag
        }
      }
      if ($1 == Channeltype: && %qncl) {
        did -ra sichanlev 8 $2
      }
      if (%qncl && $2 == Modes: && $left($3, 1) == + && $dialog(sichanlev)) {
        if ($1 == $hget(qauths, $cid)) { withstar qflagtab $did(sichanlev, 2).text $right($3,-1) }
        if (!$window(@chanlev)) { window -h @chanlev }
        aline @chanlev $1 $3
      }
      if ($1-4 == You are not known) {
        if ($dialog(sichanlev)) {
          did -b sichanlev 3
          did -b sichanlev 4
          did -b sichanlev 5
          did -b sichanlev 6
        }
        hdec temp qhide $+ $cid
        unset %qncl
      }
      if ($1-3 == End of list.) {
        if (%qncl && $dialog(sichanlev)) {
          if (!$regex($hget(qflagtab, $did(sichanlev, 2).text), [m-n]) && !$regex($hget(lflagtab, $did(sichanlev, 2).text), [m-n])) {
            did -b sichanlev 4
            did -b sichanlev 5
            did -b sichanlev 6
          }
          did -e sichanlev 3
          sicl_addlistfiltered
        }
        if (%qflags) {
          hsave -oi qflagtab lqflags.hash qflags
          yecho Q flags list updated
        }
        unset %qncl
        unset %qflags
        if ($hget(temp, qhide $+ $cid) > 0) {
          hdec temp qhide $+ $cid
          hadd -mu5 temp qhidetotal 1
          if ($dialog(sisettings)) { updlqflagslist sisettings }
          if ($hget(backupqflagtab)) { hfree backupqflagtab }
          if ($1-3 == End of list.) { haltdef | return }
        }
      }
      if ($hget(temp, qhide $+ $cid) > 0 || ($hget(temp, qhidetotal) > 0 && $1 == Total:)) {
        haltdef | return
      }
    }
  }
  if (!$appactive && $shroudget(balloon) == on && $nick != $me) {
    traydll Balloon 1 3 > Notice $+($chr(40),$nick,$chr(41)) > $strip($iif($len($1-) > 250, $left($1-, 250) $+ ..., $1-))
  }
}
on ^*:pong:{
  if (%act) {
    haltdef
    var %msg = 4,1server lag0[ $+ $calc($ticks - $gettok(%act,2,32)) $+ ms ( $+ $1 $+ ) $+ ]
    msg $gettok(%act,1,32) $statsstripx($gettok(%act,1,32), %msg)
    unset %act
  }
}
on *:connect:{
  connstate
  if ($shroudget(docheckip) == on) { checkip }
  statecheck
  .timeridlecheck [ $+ [ $cid ] ] 0 20 idlecheck
  if ($right($server,13) == .quakenet.org || $right($server,13) == .undernet.org || $isauthserv) {
    if ($siqgetnick != $null && $right($server,13) == .quakenet.org) {
      set %wantauth 1
      hidenextwho $me
      who $me n%nat,230
      return
    }
    if ($sixgetnick != $null && $right($server,13) == .undernet.org) {
      set %xwantauth 1
      hidenextwho $me
      who $me n%nat,230
      return
    }
    if ($isauthserv) {
      authservautoauth
    }
    doperformc
  }
  else { doperformc }
}
on *:logon:*:{
  k23.egg
}
on *:signal:zipsig:{
  xecho $1-
}
on *:signal:sidownload_progress:{
  update.progress $int($calc($2 / $3 * 100))
}
on *:signal:sidownload_finished:{
  if ($regex($1, /myip[0-9]*\.txt/)) { 
    var %myip = $read($1)
    echo $color(info) -s --
    echo $color(info) -s (old) ip: $ip
    scid -a localinfo %myip %myip
    hdel temp checkip
    yecho detected ip: %myip
    if ($exists($1)) { .timer 1 1 .remove $1 }
  }
  elseif ($1 == patches.lst) {
    .fopen patches patches.lst
    update.init
    while (!$feof) {
      var %u = $fread(patches)
      if (%u == -1) {
        yecho There are no updates available.
        return
      }
      if (!%once) {
        if ($?!="There's an update available for shroudIRC. Do you want to download and install it?" == $false) {
          return
        }
        else {
          statsinc updates
        }
        var %once = $true
      }
      update.add %u
    }
    update.run
    if ($fopen(patches)) { .fclose patches }
  }
  elseif (%thisifix == $1) {
    yecho Downloaded %thisifix
    dll -u shroud.dll
    unzipdll Unzip -odS zipsig $shortfn($mircdir) $+ %thisifix " $+ $shortfn($mircdir) $+ "
    if ($isfile(iscript.ini)) {
      yecho Running install script..
      .play -s iscript.ini 0
      remove iscript.ini
    }
    if ($isfile(iscript.ini3)) {
      yecho Running install script (v3)..
      reload -rs iscript3.ini
      .iscript.run
      unload -rs iscript3.ini
      remove iscript.ini
    }
    yecho Installed patch: %thisifix
    remove %thisifix
    update.next
  }
  elseif ($1 == update.html) {
    update.showhistory
  }
  elseif ($1 == feedback.html) {
    browser $+(file://,$shortfn($mircdir),feedback.html) @feedback
  }
}
on *:signal:sidownload_failed:{
  if ($1 == myip.txt) {
    yecho could not perform /checkip
    hdel temp checkip
  }
  elseif ($1 == patches.lst) {
    yecho could not get list of patches from the webserver.
  }
  elseif (%thisifix == $1) {
    yecho update $1 failed .. trying next file
    update.next
  }
  elseif ($1 == update.html) {
    update.showhistory
  }
}
alias xmsg {
  if ($left($1, 1) == =) { var %c = $right($1, -1) }
  else { var %c = $1 }
  if ($hget(bfchans, %c) != $null && $hget(bfautochans, %c) != $null) {
    xblow $1-
  }
  else {
    msg $1-
  }
}
on *:INPUT:*:{
  if (!$ctrlenter && $left($1, 1) == $readini($mircini, text, commandchar)) { statsinc cmd | return }
  statsinc input
  statsinc wordinput $numtok($1-,32)
  if ($islame($1-)) { statsinc inputlame }
  if ($left($active, 1) == =) { var %c = $right($active, -1) }
  else { var %c = $active }
  if ($hget(bfchans, %c) != $null && $hget(bfautochans, %c) != $null) {
    xblow $active $1-
    haltdef
  }
}
on *:nick:{
  var %file = $hget(nickserv, $newnick $+ / $+ $network)
  if ($me != $newnick && $me != $nick && %file && $shroudget(autoghost) != off) {
    sinsghost %file
  }
  if ($me == $nick) {
    var %d = 1
    while (%d <= $chan(0)) {
      checkbans $chan(%d)
      inc %d
    }
  }
  addr.setlast $address($newnick, 2) $newnick
  if ($hget(qauthex)) { hdel qauthex $cid $+ $nick }
  checkblacklist
}
on *:disconnect:{
  var %d = 1
  while (%d <= $chan(0)) { 
    if ($hget(kqueue. $+ $chan(%d) $+ $cid)) { hfree kqueue. $+ $chan(%d) $+ $cid }
    if ($hget(queue. $+ $chan(%d) $+ $cid)) { hfree queue. $+ $chan(%d) $+ $cid }
    inc %d
  }
  if ($hget(splitted. $+ $cid)) { hfree splitted. $+ $cid }
  if ($hget(netsplit. $+ $cid)) { hfree netsplit. $+ $cid }
  if ($hget(netjoin. $+ $cid)) { hfree netjoin. $+ $cid }
  statecheck
}
on ^*:quit:{
  if (!$isnetsplitnet) { return  }
  if (Quit !isin $1 && $0 == 2 && (. isin $1 && . isin $2) $&
    && ($gettok($1, -1, 46) isalpha && $gettok($2, -1, 46) isalpha) $&
    && ($len($gettok($1, -1, 46)) >= 2 && $len($gettok($2, -1, 46)) >= 2)) {
    var %d = 1
    while (%d <= $comchan($nick, 0)) { 
      var %a = $addtok(%a, $comchan($nick, %d), 32)
      inc %d
    }
    hadd -m3600 netsplit. $+ $cid $fulladdress %a
    .timershowsplits 1 3 showsplits
    .signal -n netsplitone $nick
    echo -st (signal) netsplitone $nick
    haltdef
  }
}
on *:quit:{
  addr.setlast $address($nick, 2) $nick
  if ($hget(qauthex)) { hdel qauthex $cid $+ $nick }  
}
on *:part:#:{
  if ($nick == $me) { push.clear $chan }
  addr.setlast $address($nick, 2) $nick
  if ($hget(qauthex)) { hdel qauthex $cid $+ $nick }  
}
on *:kick:#:{
  addr.setlast $address($nick, 2) $nick
  if ($hget(qauthex)) { hdel qauthex $cid $+ $nick }  
  if ($knick == $me) {
    push.clear $chan
    if ($network == QuakeNet) {
      var %c = $hget(qflagtab,0).item
      var %i = 1
      while (%i <= %c) {
        if ($hget(qflagtab, %i).item == $chan && o isincs $hget(lflagtab, %i).data) { join $chan }
        inc %i
      }
      var %c = $hget(lflagtab,0).item
      var %i = 1
      while (%i <= %c) {
        if ($hget(lflagtab, %i).item == $chan && o isincs $hget(lflagtab, %i).data) { join $chan }
        inc %i
      }
    }
  }
}
on *:start:{
  if ($fopen(xcorinit) != $null) { .fclose xcorinit }
  .fopen xcorinit script\init.dat
  if ($ferr) {
    yecho shroudIRC initialization failed: init.dat could not be opened
    return
  }
  while (!$feof) {
    var %cmd = $fread(xcorinit)
    %cmd
  }
  .fclose xcorinit
  return
  :error
  yecho Error - $error
}
dialog si2about {
  title "About shroudIRC"
  size -1 -1 100 63
  option dbu
  icon data\sircsmall.ico, 0
  icon 1, 3 4 16 16, data\sirc2gen.ico, 0, noborder
  text "shroudIRC 3 (xp_2504)", 2, 22 4 61 8
  text "is (c) 2004 Gunnar Beutner", 3, 22 13 67 8
  button Ok, 4, 61 46 37 12, default ok cancel
  text mIRC $version, 5, 23 24 42 8
  text "is (c) 1995-2004 mIRC Co.Ltd", 6, 23 33 74 8
}
alias si2about { if (!$dialog(si2about)) { dialog -mv si2about si2about } }
alias calcdiff_y {
  var %cd = $asctime($ctime($shroudget(birthday) 00:00), yyyy)
  var %ty = $asctime(yyyy)
  var %ydiff = $calc($ctime(31.12. $+ $asctime(yyyy)) - $ctime(1.1. $+ $asctime(yyyy)))
  var %tdiff = $calc($ctime($asctime($ctime($shroudget(birthday) 00:00), dd.mm.) $+ %ty) - $ctime)
  var %years = $calc(%ty - %cd - (%tdiff / %ydiff))
  return %years
}
alias age {
  var %secage $calc($ctime - $ctime($shroudget(birthday) 00:00))
  var %yrage $calc(%secage / 31536000)
  var %msg = 4,1my age0[ $+ $calcdiff_y $+ ] 4,1lifetime0[ $+ $duration(%secage) / %secage $+ secs]
  msg $active $statsstrip(%msg)
}
alias setbd {
  if ($1 == $null) {
    linesep
    xecho Syntax: /setbd <birthday>
    xecho Purpose: sets your birthday (used by /age)
    xecho Example: /setbd 10.02.1986
    return
  }
  shroudset birthday $$1-
}
alias siauthserv.init {
  if (!%akey) { set %akey $randqkey }
  xhmake authserv
  xhload authserv authserv.hash
  :error
  reseterror
}
alias siasauth { return $dll(shroud.dll,asauth,$$1 %akey) }
alias sisetasauth { return $dll(shroud.dll, setnsauth,$$1-2 %akey) }
alias isauthserv {
  return $hfind(authserv, */ $+ $network, 1, w)
}
alias authservautoauth {
  if ($isauthserv) {
    siasauth $hget(authserv, $v1)
  }
}
alias idlecheck {
  if ($shroudget(ahinactive) == on) {
    var %d = 1
    while (%d <= $hget(chanactivity $+ $cid, 0).item) {
      if ($calc($ctime - $hget(chanactivity $+ $cid,%d).data) > 300) {
        if ($chan($hget(chanactivity $+ $cid,%d).item) && $&
          $active != $hget(chanactivity $+ $cid,%d).item && $&
          $hget(ahxcp, $hget(chanactivity $+ $cid,%d).item) == $null) {
          window -h $hget(chanactivity $+ $cid,%d).item
        }
      }
      inc %d
    }
  }
}
alias ah.init {
  xhmake ahxcp
  xhload ahxcp ahxcp.hash
}
alias ahxcp {
  if (a $+ $1 == a) {
    var %cnt = $hget(ahxcp,0).item
    var %i = 1
    var %jback 1
    goto syntax
    :jback
    linesep
    xecho current channels:
    while (%i <= %cnt) {
      xecho $hget(ahxcp,%i).item
      inc %i
    }
    return
  }
  if ($1 == -l) {
    xhload ahxcp ahxcp.hash
    xecho channels reloaded
    return
  }
  if ($1 == -r && a $+ $2 != a) {
    hdel ahxcp $$2
    hsave -o ahxcp ahxcp.hash
    xecho $$2 removed
    return
  }
  if ($1 == -a && a $+ $2 != a) {
    hadd -m ahxcp $$2 1
    hsave -o ahxcp ahxcp.hash
    xecho $$2 added
    if ($chan($2)) { window -w $2 }
    return
  }
  :syntax
  linesep
  xecho Syntax:
  xecho   add: /ahxcp -a <channel>
  xecho   remove: /ahxcp -r <channel>
  xecho   view: /ahxcp
  xecho   reload from disk: /ahxcp -l
  if (%jback) { goto jback }
}
alias blacklist.init {
  xhmake blacklist
  xhload blacklist blacklist.hash
  :error
  reseterror
}
dialog -l blackedit {
  title $trans(EditBl)
  size -1 -1 118 46
  option dbu
  icon data\sircsmall.ico, 0
  text $trans(Mask) $+ :, 1, 4 5 25 8, right
  text $trans(Reason) $+ :, 2, 4 18 25 8, right
  edit "", 4, 32 4 83 10, autohs
  edit "", 5, 32 17 83 10, autohs
  button $trans(OK), 7, 78 30 37 12, disable default ok
  button $trans(Cancel), 8, 38 30 37 12, cancel
}
on *:dialog:blackedit:*:*:{
  if ($devent == edit) {
    if ($did(4) == $null) { did -b $dname 7 }
    else { did -e $dname 7 }
  }
  if ($did == 7 && $devent == sclick) {
    if ($chr(32) isin $did(4)) {
      xecho banmask must not contain spaces
      return
    }
    blacklist.add $did(4) $did(5)
  }
}
dialog -l blacklist {
  title "shroudIRC: Blacklist"
  size -1 -1 174 101
  option dbu
  icon data\sircsmall.ico, 0
  list 1, 3 3 168 79, size
  button $trans(Add), 3, 4 85 37 12
  button $trans(Delete), 4, 84 85 37 12
  button $trans(Edit), 2, 43 85 37 12
}
alias blacklist.show { hdump blacklist }
alias blacklist.add {
  if (!$1) {
    linesep
    xecho Syntax: /blacklist.add <hostmask> [<reason>]
    xecho Purpose: Adds <hostmask> to your blacklist with the optional paramater <reason> as the reason for kicks
    return
  }
  if ($$1 iswm *!*@*) { xecho yeah .. sure (you can't blacklist $$1 $+ ) | return }
  hadd blacklist $$1-
  hsave -o blacklist blacklist.hash
  xecho $$1 has been added to your blacklist
  checkblacklist
  if ($dialog(blacklist)) {
    updblacklist
  }
}
alias blacklist.remove {
  if (!$1) {
    linesep
    xecho Syntax: /blacklist.remove <hostmask>
    xecho Purpose: removes <hostmask> from your blacklist.
    return
  }
  if (!$hget(blacklist,$$1-).item) {
    xecho there is no such blacklist-item: $$1-
    return
  }
  hdel blacklist $$1-
  hsave -o blacklist blacklist.hash
  xecho $$1- has been removed from your blacklist
  if ($dialog(blacklist)) {
    updblacklist
  }
}
alias blacklist { dialog -mv blacklist blacklist }
alias -l updblacklist {
  var %i = 1
  var %cnt = $hget(blacklist,0).item
  did -r blacklist 1
  while (%i <= %cnt) {
    did -a blacklist 1 $hget(blacklist, %i).item $+ $iif($hget(blacklist, %i).data,$chr(9)  $+ $hget(blacklist, %i).data,$null)
    inc %i
  }
}
on *:dialog:blacklist:sclick:2:{
  tokenize 32 $did(1).seltext
  var %mask = $gettok($6, 1,9)
  var %reason = $10-
  if (%mask == $null) { return }
  dialog -mav blackedit blackedit
  did -a blackedit 4 %mask
  did -b blackedit 4
  did -a blackedit 5 %reason
  did -e blackedit 7
}
on *:dialog:blacklist:sclick:3:{
  dialog -mav blackedit blackedit
  return 
}
on *:dialog:blacklist:sclick:4:{
  var %mask = $gettok($gettok($did(1).seltext,6,32), 1,9)
  did -d blacklist 1 $did(1).sel
  blacklist.remove %mask
}
on *:dialog:blacklist:init:0:{
  mdxdll SetMircVersion $version
  mdxdll MarkDialog $dname $dialog($dname).hwnd
  mdxdll SetControlMDX $dname 1 ListView report showsel single rowselect > mdx\views.mdx
  did -i $dname 1 1 headerdims 130 180
  did -i $dname 1 1 headertext + 0 $trans(Mask) $+ $chr(9) $+ + 0 $trans(Reason)
  updblacklist
}
alias -l isblacklisted {
  var %i = 1
  var %cnt = $hget(blacklist,0).item
  while (%i <= %cnt) {
    if ($hget(blacklist, %i).item iswm $$1) {
      return $true
    }
    inc %i
  }
  return $false
}
alias checkblacklist {
  var %i = 1
  var %cnt = $hget(blacklist,0).item
  while (%i <= %cnt) {
    checkblacklistentry $hget(blacklist, %i).item $hget(blacklist, %i).data
    inc %i
  }
  var %c = 1
  while (%c <= $chan(0)) {
    pushmode.flush $chan(%c)
    inc %c
  }
}
alias -l checkblacklistentry {
  var %i = 1
  var %cnt = $chan(0)
  while (%i <= %cnt) {
    checkblacklistentrychan $chan(%i) $$1-
    inc %i
  }
}
alias -l checkblacklistentrychan {
  var %i = 1
  var %cnt = $ial($$2,0)
  while (%i <= %cnt) {
    var %nick = $ial($$2,%i).nick
    if (%nick ison $$1 && %nick != $me && $me isop $$1) {
      pushmode $1 -o %nick
      pushmode $1 +b $2
      pushkick $1 %nick blacklisted $+ $iif($3 != $null,: $3-,$null)
    }
    inc %i
  }
}
alias blowfish.init {
  xhmake bfchans
  xhmake bfautochans
  xhload bfchans bfchans.hash
  xhload bfautochans bfautochans.hash
  :error
  reseterror
}
alias bnext {
  tokenize 32 $1-
  return $2-
}
alias xsnsign {
  tokenize 32 $1-
  if ($xsnsignature($2-) == $null) { return @XSN= $+ $1- }
}
alias xsnsignature {
  tokenize 32 $1-
  if ($left($1, 5) != @XSN=) { return $null }
  else { return $right($1, -5) }
}
alias xsnmsg {
  tokenize 32 $1-
  if ($left($1, 5) != @XSN=) { return $2- }
  else { return $1- }
}
alias xblow {
  if (!$2-) { return }
  if ($left($1, 1) == =) { var %c = $right($1, -1) }
  else { var %c = $1 }
  if ($hget(bfchans,%c) != $null) {
    .!msg %c [b] $bnext($bfdll(Encrypt,$hget(bfchans,$active) $xsnsign($me, $2-)))
    if ($query(%c) == $null && $chat(%c) == $null) {
      echo -mbfti2 $1 [b] $+(<,$nick($active,$me).pnick,>) $2-
    }
    else {
      echo -mbfti2 $1 [b] $+(<,$me,>) $2-
    }
  }
  else {
    xecho You can't send an encrypted message to this channel/nick. Please specify a key for this target (/setup -> Blowfish)
  }
}
alias blow {
  if (!$1-) { return }
  xblow $active $1-
}
alias blowfish {
  if ($1 == $null) {
    var %cnt $hget(bfchans,0).item
    var %i = 1
    var %jback 1
    goto syntax
    :jback
    linesep
    xecho current chans:
    while (%i <= %cnt) {
      xecho $+($hget(bfchans,%i).item,=,$hget(bfchans,%i).data)
      inc %i
    }
    if (%cnt == 0) { xecho (no channels) }
    return
  }
  if ($1 == -l) {
    xhload bfchans bfchans.hash
    xecho chans reloaded
    return
  }
  if ($1 == -r && $2 != $null) {
    hdel bfchans $$2
    hsave -o bfchans bfchans.hash
    xecho $$2 removed
    return
  }
  if ($1 == -e && $2 != $null && $3- != $null) {
    xecho encrypted output: $bnext($bfdll(Encrypt,$2-))
    return
  }
  if ($1 == -d && $2 != $null && $3- != $null) {
    xecho decrypted output: $bnext($bfdll(Decrypt,$2-))
    return
  }
  if ($1 == -a && $2 != $null && $3- != $null) {
    hadd -m bfchans $$2 $$3
    hsave -o bfchans bfchans.hash
    xecho $$2 -> $$3
    return
  }
  if ($1 == -x && $2 != $null) {
    if ($left($2, 1) == =)  { var %c = $right($2, -1) }
    else { var %c = $2 }
    if ($hget(bfchans,%c) == $null) { xecho $$2 could not be found | return }
    if ($hget(bfautochans, %c) != $null) { hdel bfautochans %c }
    else { hadd -m bfautochans %c 1 }
    hsave -o bfautochans bfautochans.hash
    xecho toggled auto-encryption for $2 ( $+ $iif($hget(bfautochans, %c) != $null, on, off)  $+ )
    return
  }
  if ($1 == -f && $2 != $null) {
    if ($hget(bfchans, $$2) == $null) { xecho $$2 could not be found | return }
    hadd -m bfautochans $$2 1
    hsave -o bfautochans bfautochans.hash
    xecho enabled $$2
    return
  }
  if ($1 == -c && $2 != $null) {
    if ($hget(bfchans, $$2) == $null) { xecho $$2 could not be found | return }
    hdel bfautochans $$2
    hsave -o bfautochans bfautochans.hash
    xecho disabled $$2
    return
  }
  :syntax
  linesep
  xecho Syntax:
  xecho   add: /blowfish -a <chan/nick> <key>
  xecho   remove: /blowfish -r <chan/nick>
  xecho   view: /blowfish
  xecho   reload from disk: /blowfish -l
  xecho   encode: /blowfish -e <key> <plain-text>
  xecho   decode /blowfish -d <key> <text>
  xecho   toggle auto-encrypt /blowfish -x <chan/nick>
  xecho   enable auto-encrypt /blowfish -f <chan/nick>
  xecho   disable auto-encrypt /blowfish -c <chan/nick>
  if (%jback) { goto jback }
}
alias chanhide.init {
  xhmake chanhide
  xhload chanhide chanhide.hash
  :error
  reseterror
}
alias chanhide {
  if (a $+ $1 == a) {
    var %cnt $hget(chanhide,0).item
    var %i = 1
    var %jback 1
    goto syntax
    :jback
    linesep
    xecho current channels:
    while (%i <= %cnt) {
      xecho $hget(chanhide,%i).item
      inc %i
    }
    return
  }
  if ($1 == -l) {
    xhload chanhide chanhide.hash
    xecho channels reloaded
    return
  }
  if ($1 == -r && a $+ $2 != a) {
    hdel chanhide $$2
    hsave -o chanhide chanhide.hash
    if ($window($2)) {
      xasync .window -w $2
    }
    xecho $$2 removed
    return
  }
  if ($1 == -a && a $+ $2 != a) {
    hadd -m chanhide $$2
    hsave -o chanhide chanhide.hash
    xecho $$2 added
    if ($window($2)) {
      xasync .window -h $$2
    }
    return
  }
  :syntax
  linesep
  xecho Syntax:
  xecho   add: /chanhide -a <channel>
  xecho   remove: /chanhide -r <channel>
  xecho   view: /chanhide
  xecho   reload from disk: /chanhide -l
  if (%jback) { goto jback }
}
dialog -l sichanlev {
  title "shroudIRC: chanlev"
  size -1 -1 148 126
  option dbu
  icon data\sircsmall.ico, 0
  text "Channel:", 1, 5 5 24 8, right
  list 3, 5 28 139 80, disable size
  button $trans(Add), 4, 28 111 37 12
  button $trans(Remove), 5, 68 111 37 12
  button $trans(Edit), 6, 107 111 37 12
  edit "", 2, 33 4 111 10, read
  text "", 17, 15 113 8 8, hide
  text "Type:", 7, 5 17 25 8, right
  edit "not available", 8, 33 16 110 10, read
}
on *:dialog:sichanlev:*:*:{
  if ($devent == init) {
    mdxdll SetMircVersion $version
    mdxdll MarkDialog $dname $dialog($dname).hwnd
    mdxdll SetControlMDX $dname 3 ListView report showsel single rowselect shortascending > mdx\views.mdx
    did -i $dname 3 1 headerdims 180 70
    did -i $dname 3 1 headertext + 0 Auth $+ $chr(9) $+ + 0 Flags
  }
  if ($devent == sclick && $did == 3 && $did($did, 1) && $gettok($did($did, 1), 1, 32) == headerclick) { 
    sicl_filter_toggletristate
  }
  if (($devent == sclick && $did == 6) || ($devent == dclick && $did == 3)) {
    if ($did(3).sel == $null) { return }
    dialog -mv chanleved chanleved
    did -a chanleved 3 $did(2).text
    did -a chanleved 4 $gettok($gettok($did(3).seltext, 6, 32), 1, 9)
    did -a chanleved 14 $gettok($did(3).seltext, 10, 32)
    did -a chanleved 17 $did(17)
    updflagscl
  }
  if ($devent == sclick) {
    if ($did == 4) {
      var %auth = $?="Auth?"
      if (%auth != $null) {
        var %i = 1
        while (%i <= $did(3).lines) {
          if ($gettok($gettok($did(3, %i).text, 6, 32), 1, 9) == %auth) {
            dialog -mv chanleved chanleved
            did -a chanleved 3 $did(2).text
            did -a chanleved 4 $gettok($gettok($did(3, %i).text, 6, 32), 1, 9)
            did -a chanleved 14 $gettok($did(3, %i).text, 10, 32)
            did -a chanleved 17 $did(17)
            did -f chanleved 4
            updflagscl
            return
          }
          inc %i
        }
        dialog -mv chanleved chanleved
        did -a chanleved 3 $did(2).text
        did -a chanleved 4 %auth
        did -a chanleved 14 +
        did -a chanleved 17 $did(17)
        updflagscl
      }
    }
    if ($did == 5) {
      if ($did(3).sel == $null) { return }
      var %auth = $gettok($gettok($did(3).seltext, 6, 32), 1, 9)
      if (%auth == $hget(qauths, $cid)) { xecho you cannot remove yourself | return }
      did -r sichanlev 3
      set %qncl 1
      if ($did(17) == Q) {
        .msg Q CHANLEV $did(2) $chr(35) $+ %auth -amnovtb
        qhidewhois
        window -c @chanlev
        .msg Q chanlev $did(2)
      }
      else if ($did(17) == L) {
        .msg L CHANLEV $did(2) $chr(35) $+ %auth -amnovg
        lhidewhois
        window -c @chanlev
        .msg L chanlev $did(2)
      }
    }
  }
}
dialog -l chanleved {
  title "shroudIRC: chanlev"
  size -1 -1 114 105
  option dbu
  edit "", 3, 32 4 79 10, read
  text "Channel:", 1, 4 5 25 8
  text "Auth:", 2, 4 18 25 8
  edit "", 4, 32 17 79 10, read
  box "Flags", 5, 3 30 108 55
  check "&auto", 8, 7 39 46 10
  check "&give", 9, 59 39 46 10
  check "&voice", 10, 7 50 46 10
  check "&op", 11, 59 50 46 10
  check "&master", 12, 7 61 46 10
  check "ow&ner", 13, 59 61 46 10
  button $trans(Cancel), 7, 74 88 37 12, cancel
  button $trans(Ok), 6, 34 88 37 12, disable ok
  text "", 14, 4 91 6 8, hide
  check "&topic", 15, 7 72 46 10
  text "", 17, 21 91 6 8, hide
  text "", 18, 79 28 25 8, hide
  check "&ban", 19, 59 72 46 10
}
on *:dialog:chanleved:*:*:{
  if ($devent == sclick) {
    if ($did == 8) { var %flag = a }
    if ($did == 9) { var %flag = g }
    if ($did == 10) { var %flag = v }
    if ($did == 11) { var %flag = o }
    if ($did == 12) { var %flag = m }
    if ($did == 13) { var %flag = n }
    if ($did == 15) { var %flag = t }
    if ($did == 19) { var %flag = b }
    if (%flag != $null) {
      did -e chanleved 6
      var %flags = $remove($did(18).text, + $+ %flag, - $+ %flag)
      if ($did($did).state == 1) { var %flags = %flags $+ + $+ %flag }
      else { var %flags = %flags $+ - $+ %flag }
      did -o chanleved 18 1 %flags
    }
    if ($did == 6) {
      .msg $did(17) CHANLEV $did(3) $chr(35) $+ $did(4) $did(18)
      did -r sichanlev 3
      set %qncl 1
      if ($did(17) == Q) {
        qhidewhois
        window -c @chanlev
        .msg Q chanlev $did(3)
      }
      else if ($did(17)) {
        lhidewhois
        window -c @chanlev
        .msg L chanlev $did(3)
      }
    }
  }
}
alias -l updflagscl {
  if (a isincs $did(chanleved, 14)) { did -c chanleved 8 }
  if (g isincs $did(chanleved, 14)) { did -c chanleved 9 }
  if (v isincs $did(chanleved, 14)) { did -c chanleved 10 }
  if (o isincs $did(chanleved, 14)) { did -c chanleved 11 }
  if (m isincs $did(chanleved, 14)) { did -c chanleved 12 }
  if (n isincs $did(chanleved, 14)) { did -c chanleved 13 }
  if (t isincs $did(chanleved, 14)) { did -c chanleved 15 }
  if (b isincs $did(chanleved, 14)) { did -c chanleved 19 }
  if (!$regex($hget(qflagtab, $did(chanleved, 3).text), [m-n]) && !$regex($hget(lflagtab, $did(chanleved, 3).text), [m-n])) {
    did -b chanleved 8,9,10,11,12,13,15,19
  }
  if ($hget(qauths, $cid) == $did(chanleved, 4)) {
    if (a isincs $did(chanleved, 14)) { did -b chanleved 8 }
    if (g isincs $did(chanleved, 14)) { did -b chanleved 9 }
    if (v isincs $did(chanleved, 14)) { did -b chanleved 10 }
    if (o isincs $did(chanleved, 14)) { did -b chanleved 11 }
    if (m isincs $did(chanleved, 14)) { did -b chanleved 12 }
    if (n isincs $did(chanleved, 14)) { did -b chanleved 13 }
    if (t isincs $did(chanleved, 14)) { did -b chanleved 15 }
    if (b !isincs $did(chanleved, 14)) { did -b chanleved 19 }
  }
  if (n !isincs $hget(qflagtab, $did(chanleved, 3)) && n !isincs $hget(lflagtab, $did(chanleved, 3))) {
    did -b chanleved 12
    did -b chanleved 13
    if ($regex($did(chanleved, 14), [m-n])) {
      did -b chanleved 8,9,10,11,15,19
    }
  }
  if ($did(chanleved, 17) == L) {
    did -b chanleved 15,19
  }
  else {
    did -b chanleved 9
  }
}
alias sichanlev {
  if ($hget(qauths, $cid) == $null) {
    set %cldelayed 1
    set %cldelayedchan $active
    hidenextwho $me
    who $me n%nat,230
    return
  }
  if ($window(@chanlev)) { window -c @chanlev }
  unset %cldelayed*
  var %chan = $active
  if ($1 != $null) { var %chan = $1 }
  if (($2 == $null && %chan !ischan) || $network != QuakeNet) { return }
  if ($2 == $null && (L !ison %chan && Q !ison %chan && $me ison %chan)) { return }
  dialog -mv sichanlev sichanlev
  did -a sichanlev 2 %chan
  set %qncl 1
  if (Q ison %chan || Q == $2) {
    did -a sichanlev 17 Q
    qhidewhois
    .msg Q chanlev %chan
  }
  else if (L ison %chan || L == $2) {
    did -a sichanlev 17 L
    lhidewhois
    .msg L chanlev %chan
  }
}
alias sicl_addlistfiltered {
  if (!$1) {
    hadd temp siclfilter chaos
  }
  else {
    hadd temp siclfilter $1
  }
  if (!$window(@chanlev2)) { window -h @chanlev2 }
  else { clear @chanlev2 }
  if ($hget(temp, siclfilter) == chaos) {
    filter -wwa @chanlev @chanlev2
  }
  else {
    filter -wwa @chanlev @chanlev2 sicl_filter
  }
  did -r sichanlev 3
  filter -wk @chanlev2 sicl_addone
  window -c @chanlev2
}
alias sicl_filter_toggletristate {
  if ($hget(temp, siclfilter) == chaos) {
    sicl_addlistfiltered ascending
  }
  elseif ($hget(temp, siclfilter) == ascending) {
    sicl_addlistfiltered descending
  }
  elseif ($hget(temp, siclfilter) == descending) {
    sicl_addlistfiltered chaos
  }
}
alias sicl_filter {
  var %a, %b
  tokenize 32 $gettok($1, 2, 32) $gettok($2, 2, 32)
  if (n isin $1) { var %a = 10 }
  elseif (m isin $1) { var %a = 9 }
  elseif (o isin $1) { var %a = 8 }
  elseif (t isin $1) { var %a = 7 }
  elseif (v isin $1) { var %a = 6 }
  elseif (a isin $1) { var %a = 5 }
  elseif (g isin $1) { var %a = 4 }
  elseif (b isin $1) { var %a = 3 }
  if (n isin $2) { var %b = 10 }
  elseif (m isin $2) { var %b = 9 }
  elseif (o isin $2) { var %b = 8 }
  elseif (t isin $2) { var %b = 7 }
  elseif (v isin $2) { var %b = 6 }
  elseif (a isin $2) { var %b = 5 }
  elseif (g isin $2) { var %b = 4 }
  elseif (b isin $2) { var %b = 3 }
  if (%a > %b) { return $iif($hget(temp, siclfilter) == ascending, -1, 1) }
  elseif (%a < %b) { return $iif($hget(temp, siclfilter) == ascending, 1, -1) }
  else { return 0 }
}
alias sicl_addone {
  tokenize 32 $1-
  did -a sichanlev 3 0 + 0 0 0 $1 $+ $chr(9) $+ + 0 0 0 $iif($left($2, 1) != +, +) $+ $2
}
alias checkip {
  if (!$hget(temp, checkip)) {
    siasyncdownloaddirect http://www.shroudirc.net/ip.php $shortfn($mircdir) $+ myip $+ $cid $+ .txt
  }
}
alias ipset {
  if (!$istok(on off, $1, 32)) {
    linesep
    xecho Syntax: /ipset <on/off>
    xecho Purpose: enabled/disables /checkip at startup
    linesep
    xecho current value: $shroudget(docheckip)
    return
  }
  shroudset docheckip $$1
  xecho checkip set to $$1
}
alias clonescan {
  var %cnt $nick($active,0)
  var %i 1
  xhmake clonescan
  if ($chan($active).inwho) { xecho Please wait until the /who request has finished. | return }
  if (!$chan($active).ial) {
    linesep
    xechot CloneScan1
    xechot CloneScan2 $active
  }
  var %foundclones 0
  while (%i <= %cnt) {
    if ($hget(clonescan,$address($nick($active,%i),2)) == $null) {
      var %nicks = $clscanint($nick($active,%i),$active)
      if (%nicks != $null) {
        var %foundclones 1
        hadd -m clonescan $address($nick($active,%i),2) 1
        :splitnicks
        if ($len(%nicks) > 900) {
          var %charcnt $calc(800 + $pos($mid(%nicks,800,$calc($len(%nicks) - 800)),$chr(32),1))
          xecho %charcnt
          xecho $trans(ClonesOf,$nick($active,%i),$left(%nicks,%charcnt))
          var %nicks = $mid(%nicks,%charcnt,$calc($len(%nicks) - %charcnt))
          goto splitnicks
        }
        xecho Clones of $nick($active,%i) $+ : %nicks
      }
    }
    inc %i
  }
  if (%foundclones == 0) { xechot NoClones $active }
  hfree clonescan
}
alias clscanint {
  var %addr $address($1,2)
  var %cnt $ialchan(%addr,$2,0)
  var %i 1
  var %clones
  if (%cnt == $null || %cnt < 2) { return $null }
  while (%i <= %cnt) {
    var %caddr = $ialchan(%addr,$2,%i)
    var %cnick $gettok(%caddr,1,$asc(!))
    if (%cnick != $1) { var %clones [ %clones ] %cnick }
    inc %i
  }
  return %clones
}
alias getstats { 
  var %i = 1 
  while (%i <= $get(0)) { 
    var %get.pc = $calc($get(%i).pc + %get.pc) 
    var %get.cps = $get(%i).cps 
    var %get.rcvd = $calc($get(%i).rcvd + %get.rcvd) 
    var %get.files = %get.files $get(%i).file 
    inc %i 
  } 
  var %get.pc = $calc(%get.pc / $get(0)) 
  var %msg = 4,1dcc0[files downloading: ( $+ $get(0) $+ ) speed: $iif($bytes(%get.cps,3) != $null,$ifmatch,0) $+ kb/s completed: ( $+ $iif(%get.pc != $null,$ifmatch,100) $+ % ( $+ $iif($bytes(%get.rcvd,3).suf != $null,$ifmatch,0KB) $+ )) $iif($get(0) > 0, file $+ $iif($get(0) > 1,s) $+ : ( $+ %get.files $+ )) $+ $chr(93)
  msg $active $statsstrip(%msg)
}
alias sendstats { 
  var %i = 1 
  while (%i <= $send(0)) { 
    var %send.pc = $calc($send(%i).pc + %send.pc) 
    var %send.cps = $send(%i).cps 
    var %send.sent = $calc($send(%i).sent + %send.sent) 
    var %send.files = %send.files $send(%i).file 
    inc %i 
  } 
  var %send.pc = $calc(%send.pc / $send(0)) 
  var %msg = 4,1dcc0[files sending: ( $+ $send(0) $+ ) speed: ( $+ $iif($bytes(%send.cps,3) != $null,$ifmatch,0) $+ kb/s $+ ) completed: ( $+ $iif(%send.pc != $null,$ifmatch,100) $+ % ( $+ $iif($bytes(%send.sent,3).suf != $null,$ifmatch,0KB) $+ )) $iif($send(0) > 0, file $+ $iif($send(0) > 1,s) $+ : ( $+ %send.files $+ )) $+ $chr(93)
  msg $active $statsstrip(%msg)
} 
alias dccstats { 
  sendstats 
  getstats 
}
dialog -l feedback {
  title shroudIRC: $trans(Feedback)
  size -1 -1 191 123
  option dbu
  icon data\sircsmall.ico, 0
  text $trans(Type) $+ :, 7, 3 4 21 8, right
  combo 1, 27 3 112 54, size drop
  text $trans(Text) $+ :, 10, 3 43 21 8, right
  text $trans(Nick) $+ :, 8, 3 17 21 8, right
  edit "", 2, 27 16 112 10, read
  edit "", 3, 27 29 112 10
  edit "", 4, 27 42 161 64, multi return autohs autovs
  button $trans(Send), 5, 111 109 37 12, default ok
  button $trans(Abort), 6, 151 109 37 12, cancel
  text $trans(Subject) $+ :, 9, 3 30 21 8, right
}
alias feedback { if (!$dialog(feedback)) { dialog -mv feedback feedback } }
alias -l fbtext {
  var %i = 1
  var %tx
  while (%i <= $did(4).lines) {
    var %tx = [ [ %tx ] ] $+ $iif(%tx != $null, % $+ 0D $+ % $+ 0A) $+ $replace($did(4, %i).text, $chr(32), % $+ 20)
    inc %i
  }
  return %tx
}
on *:dialog:feedback:*:*:{
  if ($devent == init) {
    did -a $dname 2 $me
    did -a $dname 1 $trans(BugReport)
    did -a $dname 1 $trans(FeatureReq)
    did -a $dname 1 $trans(misc)
    did -c $dname 1 1
  }
  if ($devent == sclick && $did == 5) {
    var %url = http://www.shroudirc.net/feedback.php?type= $+ $remove($did(1).seltext, $chr(32)) $+ &nick= $+ $did(2) $+ &subject= $+ $replace($did(3), $chr(32), % $+ 20) $+ &text= $+ $fbtext
    siasyncdownload %url $mircdir $+ feedback.html
  }
}
alias filter.init {
  xhmake wordfilter
  xhload wordfilter filter.hash
}
alias filtermsg {
  var %cnt $hget(wordfilter,0).item
  var %i = 1
  if ($shroudget(xfilter) == off) { return $false }
  while (%i <= %cnt) {
    var %f = $hget(wordfilter, %i).data
    if (* !isin %f && ? !isin %f) {
      if (%f isin $strip($1-,burc)) { return $true }
    }
    else {
      if (* $+ %f $+ * iswm $strip($1-,burc)) { return $true }
    }      
    inc %i
  }
  return $false
}
alias wordfilter {
  if (a $+ $1 == a) {
    var %cnt $hget(wordfilter,0).item
    var %i = 1
    var %jback 1
    goto syntax
    :jback
    linesep
    xecho wordfilter is $iif($shroudget(xfilter) == off, off, on)
    linesep
    xecho current phrases:
    while (%i <= %cnt) {
      xecho $hget(wordfilter,%i).data
      inc %i
    }
    if (%cnt == 0) { xecho (none) }
    return
  }
  if ($1 == -l) {
    xhload wordfilter filter.hash
    xecho channels reloaded
    return
  }
  if ($1 == -r && a $+ $2 != a) {
    var %e = $hfind(wordfilter, $$2-, 1, w).data
    if (%e == $null) {
      xecho not found
      return
    }
    hdel wordfilter %e
    hsave -o wordfilter filter.hash
    xecho ' $+ $$2- $+ ' removed
    return
  }
  if ($1 == -a && a $+ $2 != a) {
    hadd -m wordfilter n $+ $suid $$2-
    hsave -o wordfilter filter.hash
    xecho ' $+ $$2- $+ ' added
    return
  }
  if ($1 == -b) {
    xecho disabled wordfilter
    shroudset xfilter off
    return 
  }
  if ($1 == -e) {
    xecho enabled wordfilter
    shroudset xfilter on
    return 
  }
  :syntax
  linesep
  xecho Syntax:
  xecho   add: /wordfilter -a <phrase>
  xecho   remove: /wordfilter -r <phrase>
  xecho   enable: /wordfilter -e
  xecho   disable: /wordfilter -b
  xecho   view: /wordfilter
  xecho   reload from disk: /wordfilter -l
  if (%jback) { goto jback }
}
alias fkeys.init {
  xhmake fkeys
  xhload fkeys fkeys.hash
  xasync dofkeys
  :error
  reseterror
}
alias dofkeys {
  var %cnt $hget(fkeys,0).item
  var %i = 1
  .unload -a script\afkeys.ini
  while (%i <= %cnt) {
    writeini script\afkeys.ini aliases n $+ $calc(%i - 1) / $+ $hget(fkeys,%i).item $hget(fkeys,%i).data
    inc %i
  }
  .reload -a script\afkeys.ini
}
alias fkeys {
  if ($1 == $null) {
    var %cnt $hget(fkeys,0).item
    var %i = 1
    var %jback 1
    goto syntax
    :jback
    linesep
    xecho current f-keys:
    while (%i <= %cnt) {
      if ($hget(fkeys,%i).data != $null) { xecho $hget(fkeys,%i).item -> $hget(fkeys,%i).data }
      inc %i
    }
    return
  }
  if ($1 == -l) {
    xhload fkeys fkeys.hash
    xecho f-keys reloaded
    dofkeys
    return
  }
  if ($1 == -r && $2 != $null) {
    hadd -m fkeys $$2
    hsave -o performchans performc.hash
    xecho $$2 removed
    dofkeys
    return
  }
  if ($1 == -a && $2 != $null) {
    hadd -m fkeys $$2 $3-
    hsave -o fkeys fkeys.hash
    xecho $$2 -> $$3- added
    dofkeys
    return
  }
  if ($1 == -as && $2 != $null) {
    hadd -m fkeys $$2 $3-
    hsave -o fkeys fkeys.hash
    dofkeys
    return
  }
  :syntax
  linesep
  xecho Syntax:
  xecho   add: /fkeys -a <key> </alias>
  xecho   remove: /fkeys -r <key>
  xecho   view: /fkeys
  xecho   reload from disk: /fkeys -l
  if (%jback) { goto jback }
}
alias fkeysv {
  return $hget(fkeys,$$1)
}
alias resetsihaltdef {
  hadd -m temp haltdef 0
}
alias sihaltdef {
  hadd -m temp haltdef 1
}
alias sihalted {
  return $iif($hget(temp, haltdef), $true, $false)
}
alias tray.init {
  traydll Delete 1
  traydll DoTray sitray 1 > data\sirc2gen.ico > shroudIRC
}
alias core.init {
  if (%shroudf == on) {
    if ($readini($mircdir $+ \language.ini, language, id) != $null) { shroudset language $ifmatch }
    else { shroudset language 1033 }
  }
  language.load 1033
  if ($shroudget(language)) { language.load $shroudget(language) }
  xecho using language ' $+ $trans(NativeName) $+ '
  yecho --
  if (%shroudf == on) {
    if ($readini($mircdir $+ \language.ini, language, id) != $null) { shroudset language $ifmatch }
    else { shroudset language 1033 }
    readme
    unset %shroudf
  }
  else {
    xasync doperformn
  }
  inc %startnum
  yecho $+(shroudIRC has already been run %startnum time,$iif(%startnum == 0 || %startnum > 1, s),.)
  yecho $round($calc($uptime(mirc, N) / 1000), 2) seconds were needed for loading $script(0) script files.
  if ($shroudget(autoupdate) == on) { xasync checkupdates }
  xasync tray.init
  :error
  reseterror
}
alias sitray {
  if ($1 == ldclick) {
    dmudll HideMirc off
  }
  if ($1 == rdclick) {
    dmudll HideMirc on
    traydll Balloon 1 3 > Tray > mIRC was sent to the tray. Doubleclick on this icon to re-enable it.
  }
}
alias xecho {
  if ($1 == $null) {
    echo $color(info) -a xecho called with $ $+ null-arg
  }
  else {
    echo $color(info) -a $$1-
  }
}
alias xechot {
  if (!$1) {
    echo $color(info) -a xechot called with $ $+ null-arg
  }
  else {
    echo $color(info) -a $trans($1, $2-)
  }
}
alias yecho {
  if ($1 == $null) {
    echo $color(info) -s yecho called with $ $+ null-arg
  }
  else {
    echo $color(info) -s $$1-
  }
}
alias xnull { return $null }
alias xhmake {
  if ($hget($1)) {
    hfree $1
  }
  hmake $1 40
}
alias yhmake {
  if (!$hget($1)) {
    hmake $1 40
  }
}
alias xhload {
  if (!$exists($2-)) { hsave -o $1 $shortfn($2-) }
  hload $1 $shortfn($2-)
  return
  :error
  yecho xhload failed: $2 could not be loaded
  reseterror
}
alias xasync {
  .timer 1 0 $1-
}
alias ifnotpatch {
  if ($left($shroudget(patchlevel), 4) <= $left($1, 4)) {
    if ($right($shroudget(patchlevel),$calc($len($shroudget(patchlevel)) - 4)) < $right($1, $calc($len($1) - 4))) { $2- }
  }
}
alias lag {
  %act = $active
  if $1 == -s {
    .raw PING $ticks
    %act = %act $ticks
  }
  else {
    .ctcp $me LAG $ticks
  }
}
alias logview {
  window -aezl40k0 @LogView
  lv.list $logdir
  lv.list $mid($$1-,1,$decr($pos($$1-,\,$count($$1-,\))))
  lv.load $$1-
}
alias lv.list {
  var %dir = $replace($$1-,\\,\) $+ \
  hadd -m logview dir %dir
  dline -l @LogView 1-
  if ($logdir $+ \ != %dir) { aline -lp @LogView \.. }
  lv.listhash d %dir
  lv.orderhash
  lv.listwrite \
  lv.listhash f %dir
  lv.orderhash
  lv.listwrite
}
alias lv.orderhash {
  window -sh @LogViewTemp
  var %i = 1, %j = $hget(lvhash,0).item
  while (%i <= %j) {
    aline @LogViewTemp $hget(lvhash,%i).item
    inc %i
  }
  hdel -w lvhash *
}
alias lv.switchhash {
  var %b = $hget(lvhash,$$2) 
  var %a = $hget(lvhash,$1)
  hadd lvhash $1 %b
  hadd lvhash $2 %a
}
alias lv.listhash {
  var %dir = $$2-
  var %len = $incr($len(%dir))
  if ($hget(lvhash)) { hdel -w lvhash * }
  var %i = 1
  if ($1 == d) { var %j = $finddir(%dir,*,0,1) }
  if ($1 == f) { var %j = $findfile(%dir,*.log,0,1) }
  while (%i <= %j) {
    if ($1 == d) { hadd -m lvhash $mid($finddir(%dir,*,%i,1),$decr(%len)) }
    if ($1 == f) {
      var %file = $mid($findfile(%dir,*.log,%i,1),$decr(%len))
      if ($left(%file,1) == \) { var %file = $mid(%file,2) }
      hadd -m lvhash %file
    }
    inc %i
  }
}
alias lv.listwrite {
  var %i = 1, %j = $line(@LogViewTemp,0)
  while (%i <= %j) {
    aline -lp @LogView $1 $+ $line(@LogViewTemp,%i)
    inc %i
  }
  window -c @LogViewTemp
}
alias lv.dclick {
  var %dir = $hget(logview,dir)
  var %select = $strip($sline(@LogView,1),b)
  if ($1) {
    if ($isdir(%dir $+ %select)) { lv.list %dir $+ %select }
    if ($isfile(%dir $+ %select)) { lv.load %dir $+ %select }
    if (%select == \..) { 
      var %num = $count(%dir,\)
      var %num = $decr(%num)
      var %num = $pos(%dir,\,%num)
      lv.list $mid(%dir,1,%num)
    }
  }
  else {
    lv.dialog
  }
}
alias lv.load {
  var %file = $$1-
  var %i = 1, %j = $lines(%file)
  if ($hget(logview,strip)) { var %para = -fwcb }
  else { var %para = -fwc }
  hadd logview data %file
  var %mask = $hget(logview,c.mask)
  if (!%mask) { var %mask = * }
  filter -pfwcb $shortfn(%file) @LogView %mask
}
alias lv.find {
  var %match = $$2-, %num = $1
  var %line = $fline(@LogView,%match,%num)
  if (!%line) { return }
  sline @LogView %line
}
menu @LogView {
  dclick:/lv.dclick $1-
}
dialog -l logview {
  title "shroudIRC: logviewer"
  size -1 -1 129 49
  option dbu
  icon data\sircsmall.ico, 0
  text "search:", 3, 3 4 25 8
  text "filter logs:", 4, 3 18 25 8
  edit "*", 1, 31 3 95 10
  edit "", 2, 31 17 95 10
  button "Ok", 6, 88 31 37 12, ok cancel
  button "Search", 7, 11 31 37 12
  button "Apply", 8, 50 31 37 12
}
on *:dialog:logview:*:*:{
  if ($devent == sclick && ($did == 6 || $did == 8) && $hget(logview,c.mask) != $did(logview,2).text) {
    hadd -m logview c.mask $did(logview,2).text
    lv.load $hget(logview,data)
  }
  if ($devent == sclick && $did == 7) {
    var %match = * $+ $did(logview,1).text $+ *
    var %max = $fline(@LogView,%match,0)
    if (%match == $hget(logview,find)) {
      hinc logview find.num
      var %num = $hget(logview,find.num)
      if (%num > %max) { var %num = 1 }
      if (%max == 0) { var %num = 0 }
      hadd logview find.num %num
    }
    else {
      hadd logview find %match
      hadd logview find.num 1
      var %num = 1
    }
    var %txt = Search ( $+ %num $+ / $+ %max $+ )
    did -o logview 7 1 %txt
    lv.find %num %match
  }
  if ($devent == init) {
    if ($hget(logview,c.mask)) { did -a logview 2 $hget(logview,c.mask) }
    else { did -a $dname 2 * }
  }
}
alias lv.dialog if ($window(@LogView) && !$dialog(logview)) { dialog -mv logview logview }
alias incr return $calc($$1 + $iif($2,$2,1))
alias decr return $calc($$1 - $iif($2,$2,1))
alias logviewer logview $1-
alias logvwev {
  aline @logviewer $1-
}
alias logviewer {
  if ($shroudget(logvwfiles) == $null) {
    tokenize 32 *
  }
  else {
    tokenize 32 * $+ $shroudget(logvwfiles) $+ *
  }
  window -aeSzl40k0 @LogViewer
  aline @logviewer Doubleclick here to show the setup dialog
  xnull $findfile($logdir, $1-, 0, aline -l @logviewer $remove($1-, $logdir))
}
alias logvwloadx {
  if ($1 != $null) {
    hadd -m temp logvw $1-
    filter -czp $shortfn($1-) @logviewer * $+ $shroudget(logvwlogs) $+ *
  }
}
alias logvwload {
  if ($1 == @lvreload) {
    if ($hget(temp, logvw)) { logvwloadx $hget(temp, logvw) }
  }
  else if ($1 != $null) {
    hadd -m temp logvw $iif($1 !isnum, $1-, $sline(@logviewer,1)))
    filter -czp $shortfn($logdir $+ $iif($1 !isnum, $1, $sline(@logviewer,1))) @logviewer * $+ $shroudget(logvwlogs) $+ *
  }
  else {
    logvwopt
  }
}
menu @logviewer {
  dclick:/logvwload $1-
}
dialog -l logvwopt {
  title "shroudIRC: logviewer"
  size -1 -1 129 49
  option dbu
  icon data\sircsmall.ico, 0
  text "filter files:", 3, 3 4 25 8
  text "filter logs:", 4, 3 18 25 8
  edit "", 1, 31 3 95 10
  edit "", 2, 31 17 95 10
  button "Close", 6, 88 31 37 12, ok cancel
}
on *:dialog:logvwopt:*:*:{
  if ($devent == init) {
    if ($shroudget(logvwfiles)) { did -a $dname 1 $ifmatch }
    else { did -a $dname 1 * }
    if ($shroudget(logvwlogs)) { did -a $dname 2 $ifmatch }
    else { did -a $dname 2 * }
    if ($shroudget(logvwfilter) == on) { did -c $dname 5 }
  }
  if ($devent == edit) {
    if ($did == 1) { shroudset logvwfiles $did($did).text | dline -l @logviewer 1- $+ $line(@logviewer,0,1) | xnull $findfile($logdir, * $+ $shroudget(logvwfiles) $+ *, 0, aline -l @logviewer $remove($1-, $logdir)) }
    if ($did == 2) { shroudset logvwlogs $did($did).text | logvwload @lvreload }
  }
}
alias logvwopt { if ($window(@logviewer) && !$dialog(logvwopt)) { dialog -mv logvwopt logvwopt } }
alias lqflags.init {
  xhmake qflagtab
  xhmake lflagtab
  hload -i qflagtab lqflags.hash qflags
  hload -i lflagtab lqflags.hash lflags
  :error
  reseterror
}
alias lqflags {
  lflags
  qflags
  yecho updating flags list..
}
alias lflags {
  if ($network != QuakeNet) { return }
  xhmake backuplflagtab
  hload -i backuplflagtab lqflags.hash lflags
  xhmake lflagtab
  lhidewhois
  set %lflags 1
  ifnet .quakenet.org msg L whois $me
}
alias qflags {
  if ($network != QuakeNet) { return }
  xhmake backupqflagtab
  hload -i backupqflagtab lqflags.hash qflags
  xhmake qflagtab 20
  qhidewhois
  set %qflags 1
  ifnet .quakenet.org msg Q whois $me
}
alias recoverflags {
  var %lflag $hget(lflagtab,$1)
  var %qflag $hget(qflagtab,$1)
  if (* !isin $hget(qflagtab,$1)) {
    if (o isin %qflag) {
      ifnet quakenet.org msg Q op $1
      return
    }
    if (v isin %qflag) {
      ifnet quakenet.org msg Q voice $1
    }
  }
  if (* !isin $hget(lflagtab,$1)) {
    if (o isin %lflag) {
      ifnet quakenet.org msg L op $1
      return
    }
    if (v isin %lflag) {
      ifnet quakenet.org msg L voice $1
    }
  }
}
alias join {
  if (b isin $hget(qflagtab,$1) && $network == QuakeNet) {
    xecho Why do you want to join $1 $+ ? You'll get banned there anyways ..
  }
  join $1-
}
alias lhidewhois {
  hinc -m temp lhide $+ $cid
}
alias qhidewhois {
  hinc -m temp qhide $+ $cid
}
menu status {
  $trans(SStats)
  .$trans(SAvailCmds):/stats m
  .$trans(SShowAdmin):/admin
  .$trans(SShowUptime):/stats u
  $trans(SServer)
  .$trans(SLusers):/lusers
  .$trans(SMOTD):/motd
  .$trans(STime):/time
  $trans(SNewStatWnd):/server -n
  $trans(SList):/list
  $trans(SModes)
  .$trans(SInvHost)
  ..$trans(SOn):/mode $me +x
  ..$trans(SOff):/mode $me -x
  .$trans(SInvisible)
  ..$trans(SOn):/mode $me +i
  ..$trans(SOff):/mode $me -i
  .$trans(SSnotice)
  ..$trans(SOn):/mode $me +s
  ..$trans(SOff):/mode $me -s
  .$trans(SWallops)
  ..$trans(SOn):/mode $me +w
  ..$trans(SOff):/mode $me -w
  .$trans(SGlobOps)
  ..$trans(SOn):/mode $me +g
  ..$trans(SOff):/mode $me -g
}
menu menubar {
  $iif(%si2dev, $trans(Google)):/run http://www.google.com
  $iif(%si2dev, $trans(DictENDE)):/run http://dict.leo.org/
  $iif(%si2dev, $trans(DictENSWE)):/run http://www-lexikon.nada.kth.se/skolverket/swe-eng.shtml
  $iif(%si2dev, -)
  $trans(Setup):setup
  $trans(Stats)
  .$iif($shroudget(statsnocolors) != on, $style(1)) $trans(UseColors):/statstogglecolors
  .-
  .$trans(Age):/age
  .$trans(DccStats):dccstats
  .$trans(GenStats):stat
  .$trans(GfxStats):screenstat
  .$trans(Network):nistat
  .Disks:diskstat
  .$trans(LagStats):lag
  .$trans(ServerLagStats):lag -s
  .$trans(shroudIRCStats):sistat
  .$trans(MP3Stats):smp3
  .$trans(Misc):si2statsdlg
  $iif($away, $style(1)) $trans(Away)
  .$iif($away, $style(2)) $trans(SetAway):/aw
  .$iif($away, $style(2)) $trans(SetAwayCustom):/aw $$?="Away message?"
  .$iif(!$away, $style(2)) $trans(SetBack):/back
  $trans(Misc)
  .$iif($isalias(qb), $trans(QB)) :qb
  .$trans(MLock):modelock
  .$trans(Blacklist):blacklist
  .$trans(KTE):kte_load
  .$chanhaslq $trans(sicl):sichanlev
  .$trans(Modules):modloader
  .$trans(Feedback):feedback
  $ischaron(Dev)
  .$ischaron(Language editor):run $mircdir $+ SILang.exe
  .$ischaron(Reload language):language.rehash
  .$ischaron(Concat):run $mircdir $+ script\SIConcat.exe
  .$ischaron(WebIfc):run http://www.shroudirc.net/index.php?p=dev
  $iif($hget(modules, 0).item > 0, $trans(Modules))
  .$submenu($modmenu($1))
  -
  $trans(Vote):vote
}
alias cmod {
  return $iif($2 isincs $gettok($chan($1).mode, 1, 32), $true, $false)
}
alias ctogg {
  if ($cmod($1, $2)) {
    return - $+ $2 $iif($2 == k, $chan($1).key)
  }
  else { return + $+ $2 $iif($2 == k || $2 == l, $input(Parameter?, e)) }
}
alias mbans {
  if ($2 == begin || $2 == end) { return }
  if ($2 == 1 && $ibl($1, 0) == 0) { return }
  if ($2 == 1) { return Clear All:mclearbans $1 }
  if ($2 == 2) { return - }
  if ($ibl($1, $calc($2 - 2)) != $null) {
    return $style(1) $ibl($1, $calc($2 - 2)) $+ :mode $1 -b $ibl($1, $calc($2 - 2))
  }
}
alias mclearbans {
  if ($network == QuakeNet || $network == UnderNet) {
    mode $iif($1,$1,$$chan) +b-b *!*@* *!*@*
    return
  }
  var %d = 1
  while (%d <= $ibl($iif($1,$1,$$chan), 0)) {
    pushmode $iif($1,$1,$$chan) -b $ibl($iif($1,$1,$$chan), %d)
    inc %d
  }
}
menu channel {
  Channel
  .Modes
  ..$iif($cmod($chan, n), $style(1)) No extern. msg	+n:mode $chan $ctogg($chan, n)
  ..$iif($cmod($chan, t), $style(1)) Ops set topic	+t:mode $chan $ctogg($chan, t)
  ..$iif($cmod($chan, m), $style(1)) Moderated	+m:mode $chan $ctogg($chan, m)
  ..$iif($cmod($chan, p), $style(1)) Private	+p:mode $chan $ctogg($chan, p)
  ..$iif($cmod($chan, s), $style(1)) Secret	+s:mode $chan $ctogg($chan, s)
  ..$iif($cmod($chan, k), $style(1)) Key	+k:mode $chan $ctogg($chan, k)
  ..$iif($cmod($chan, l), $style(1)) Limit	+l:mode $chan $ctogg($chan, l)
  ..$iif($cmod($chan, i), $style(1)) Invite only	+i:mode $chan $ctogg($chan, i)
  ..$iif(c isincs $chanmodes, $iif($cmod($chan, c), $style(1)) No colors	+c):mode $chan $ctogg($chan, c)
  ..$iif(r isincs $chanmodes, $iif($cmod($chan, r), $style(1)) Registered only	+r):mode $chan $ctogg($chan, r)
  ..$iif(D isincs $chanmodes, $iif($cmod($chan, D), $style(1)) Auditorium	+D):mode $chan $ctogg($chan, D)
  ..$iif(C isincs $chanmodes, $iif($cmod($chan, C), $style(1)) No CTCP	+C):mode $chan $ctogg($chan, C)
  ..$iif(N isincs $chanmodes, $iif($cmod($chan, N), $style(1)) No notices	+N):mode $chan $ctogg($chan, N)
  ..$iif(u isincs $chanmodes, $iif($cmod($chan, u), $style(1)) Hide quit-msgs	+u):mode $chan $ctogg($chan, u)
  .Bans $iif($ibl($chan,0) > 0, $chr(40) $+ $ifmatch $+ $chr(41))
  ..$submenu($mbans($chan, $1))
  .Tools
  ..$iif($chan(#).ial, $style(2)) Refresh IAL:hidenextwho $chan | who $chan | xecho Updating IAL..
  ..$iif(!$chan(#).ial, $style(2)) Clonescan:clonescan
  .Log
  ..View:logview $chan($chan).logfile
  ..Search:logview $chan($chan).logfile | lv.dialog
  -
  $trans(Setup):setup
  $trans(Stats)
  .$iif($shroudget(statsnocolors) != on, $style(1)) $trans(UseColors):/statstogglecolors
  .-
  .$trans(Age):/age
  .$trans(DccStats):/dccstats
  .$trans(GenStats):/stat
  .$trans(GfxStats):/screenstat
  .$trans(Network):/nistat
  .Disks:diskstat
  .$trans(LagStats):/lag
  .$trans(ServerLagStats):/lag -s
  .$trans(shroudIRCStats):/sistat
  .$trans(MP3Stats):/smp3
  .$trans(Misc):/si2statsdlg
  $iif($away, $style(1)) $trans(Away)
  .$iif($away, $style(2)) $trans(SetAway):/aw
  .$iif($away, $style(2)) $trans(SetAwayCustom):/aw $$?="Away message?"
  .$iif(!$away, $style(2)) $trans(SetBack):/back
  $trans(Misc)
  .$iif($isalias(qb), $trans(QB)) :qb
  .$trans(MLock):modelock
  .$trans(Blacklist):blacklist
  .$trans(KTE):kte_load
  .$chanhaslq $trans(sicl):sichanlev
  .$trans(Modules):modloader
  .$trans(Feedback):feedback
  $ischaron(Dev)
  .$ischaron(Language editor):run $mircdir $+ SILang.exe
  .$ischaron(Reload language):language.rehash
  .$ischaron(Concat):run $mircdir $+ script\SIConcat.exe
  .$ischaron(WebIfc):run http://www.shroudirc.net/index.php?page=dev
  $iif($hget(modules, 0).item > 0, $trans(Modules))
  .$submenu($modmenu($1))
  -
  $trans(Vote):vote
}
menu query {
  $trans(Whois):/w $$1
  $isqnet $trans(QWhois):/qw $$1
  $isqnet $trans(LWhois):/lw $$1
  -
  $trans(Ignore):/ignore $$1 1 | /closemsg $$1
  $trans(CTCP)
  .$trans(Ping):/ctcp $$1 ping
  .$trans(Time):/ctcp $$1 time
  .$trans(Version):/ctcp $$1 version
  .$trans(Finger):/ctcp $$1 finger
  $trans(Dcc)
  .$trans(DccSend):/dcc send $$1
  .$trans(DccChat):/dcc chat $$1
  -
  $trans(Slap):/slap $$1
}
menu nicklist {
  $iif($1, $meishop $trans(Quickkick)) :/k $$1 | /k $$2 | /k $$3 | /k $$4 | /k $$5 | /k $$6 | /k $$7 | /k $$8 | /k $$9 | /k $$10 | /k $$11 | /k $$12 | /k $$13 | /k $$14 | /k $$15
  $iif($1, $meishop $trans(Quickbankick)) :/xbankick $active $$1 | /xbankick $active $$2 | /xbankick $active $$3 | /xbankick $active $$4
  -
  $iif($1, $trans(Whois)) :/w $$1
  -
  $iif($1, $meishop $trans(Massvoice)) :/massvoice $$active
  $iif($1, $meishop $trans(Massdevoice)) :/massdevoice $$active
  -
  $iif($1, $trans(Control))
  .$meisop $trans(Op):pushm $active +o $1-
  .$meisop $trans(Deop):pushm $active -o $1-
  .$iif(h isincs $chanmodes, $meisop $trans(HalfOp)) :pushm $active +h $1-
  .$iif(h isincs $chanmodes, $meisop $trans(DeHalfOp)) :pushm $active -h $1-
  .$meishop $trans(Voice):pushm $active +v $1-
  .$meishop $trans(Devoice):pushm $active -v $1-
  .$meishop $trans(Kick):pushk $active $1-
  .$meishop $trans(KickCustom):k $$1 $$?="Reason?" | /k $$2 $$?="Reason?" | /k $$3 $$?="Reason?" | /k $$4 $$?="Reason?"
  .$meishop $trans(KickRandom):k $$1 $read(data\kick.txt) | /k $$2 $read(data\kick.txt) | /k $$3 $read(data\kick.txt) | /k $$4 $read(data\kick.txt)
  .$meishop $trans(Ban):pushkb $active $false $1-
  .$meishop $trans(BanKick):pushkb $active $true $1-
  .$meishop $trans(BanKickCustom):/xbankick $active $$1 $true $$?="Reason?" | /xbankick $active $$2 $true $$?="Reason?" | /xbankick $active $$3 $true $$?="Reason?" | /xbankick $active $$4 $true $$?="Reason?"
  .$meishop $trans(BanKickRandom):/xbankick $active $$1 $true $read(data\kick.txt) | /xbankick $active $$2 $true $read(data\kick.txt) | xbankick $active $$3 $read(data\kick.txt) | xbankick $active $$4 $true $read(data\kick.txt)
  .$iif(!$chan($1).ial, $style(2)) $trans(Blacklist):/blacklist.add $address($$1, 3)
  .$trans(BlacklistNick):/blacklist.add $$1 $+ !*@*
  $iif($1, $trans(User))
  .$trans(Ignore):/ignore $$1 $shroudget(banmask)
  .$trans(Unignore):/ignore -r $$1 $shroudget(banmask)
  .$trans(Invite):/invite $$1 $$input($trans(EnterInvite, $$1),e)
  .$trans(SendMessage):/msg $$1 $$input($trans(EnterMsg, $$1),e)
  .$trans(SendNotice):/notice $$1 $$input($trans(EnterNotice, $$1),e)
  .$trans(Query):/query $$1
  .$trans(NotifyMe):/notify $$1
  $iif($1, $trans(CTCP))
  .$trans(Ping):/ctcp $$1 PING
  .$trans(Time):/ctcp $$1 TIME
  .$trans(Version):/ctcp $$1 VERSION
  .$trans(Finger):/ctcp $$1 FINGER
  $iif($1, $trans(Dcc))
  .$trans(DccSend):/dcc send $$1
  .$trans(DccChat):/dcc chat $$1
  $iif($1, $isqnet $trans(QNet))
  .$trans(QWhois):qw $$1
  .$trans(LWhois):lw $$1
  .$trans(Flags)
  ..$chanhaslqchkflags Set +av:setqnflag $active $$1 +av
  ..$chanhaslqchkflags Set -av:setqnflag $active $$1 -av
  ..-
  ..$chanhaslqchkflags Set +ao:setqnflag $active $$1 +ao
  ..$chanhaslqchkflags Set -ao:setqnflag $active $$1 -ao
  ..-
  ..$chanhaslqchkflagsn Set +m:setqnflag $active $$1 +m
  ..$chanhaslqchkflagsn Set -m:setqnflag $active $$1 -m
  ..-
  ..$trans(UpdMyFlags):lqflags
  -
  $iif($1, $trans(Slap)) :/slap $$1
  -
  $iif($1, $trans(Idletime) $duration($nick($active,$1).idle) :/)
  $iif($isalias(_shroudidc) && $$1, Allow query (15m)):tempqallow $$1
}
alias pushm {
  var %d = 1
  while (%d <= $calc($0 - 2)) {
    pushmode $1 $left($2, 2) $gettok($3-, %d, 32)
    inc %d
  }
}
alias pushk {
  var %d = 1
  while (%d <= $calc($0 - 1)) {
    pushkick $1 $gettok($2-, %d, 32)
    inc %d
  }
}
alias pushkb {
  var %d = 1
  while (%d <= $calc($0 - 2)) {
    xbankick $1 $gettok($3-, %d, 32) $2
    inc %d
  }
}
alias massvoice {
  var %i 1
  var %cnt 0
  if (!$1) { return }
  while (%i <= $nvnick($1,0)) {
    var %nnicks = %nnicks $nvnick($1, %i)
    inc %cnt
    if (%cnt == $modespl) {
      mode $1 + $+ $str(v, $modespl) %nnicks
      var %nnicks
      var %cnt 0
    }
    inc %i
  }
  mode $1 + $+ $str(v, $modespl) %nnicks
}
alias massdevoice {
  var %i 1
  var %cnt 0
  if (!$1) { return }
  while (%i <= $vnick($1,0)) {
    var %vnicks = %vnicks $vnick($1,%i)
    inc %cnt
    if (%cnt == $modespl) {
      mode $1 - $+ $str(v, $modespl) %vnicks
      var %vnicks
      var %cnt 0
    }
    inc %i
  }
  mode $1 - $+ $str(v, $modespl) %vnicks
}
alias statstogglecolors {
  if ($shroudget(statsnocolors) == on) {
    shroudset statsnocolors off
  }
  else {
    shroudset statsnocolors on
  }
}
alias meisop {
  if ($me isop $iif($1, $1, $active)) {
    return $null
  }
  else {
    return $style(2)
  }
}
alias meishop {
  if ($me ishop $iif($1, $1, $active) || $me isop $iif($1, $1, $active)) {
    return $null
  }
  else {
    return $style(2)
  }
}
alias isqnet {
  if ($network == QuakeNet) { return $null }
  else { return $style(2) }
}
alias chanhaslq {
  if ((L !ison $active && Q !ison $active) || $network != QuakeNet) { return $style(2) }
  else { return $null }
}
alias chanhaslqchkflags {
  if ((L !ison $active && Q !ison $active) || $network != QuakeNet) { return $style(2) }
  else { return $iif(!$lqhasflag($active, m), $style(2)) }
}
alias chanhaslqchkflagsn {
  if ((L !ison $active && Q !ison $active) || $network != QuakeNet) { return $style(2) }
  else { return $iif(!$lqhasflag($active, n), $style(2)) }
}
alias ischaron {
  if (%si2dev == 1) { return $1- }
  else { return $null }
}
alias lqhasflag {
  if ($2 isin $hget(qflagtab,$1)) { return $true }
  if ($2 isin $hget(lflagtab,$1)) { return $true }
  return $false
}
alias mlock.init {
  xhmake atake
  xhload atake atake.hash
  :error
  reseterror
}
alias lban {
  if ($$1 != !noauth) { mode $$2 +b *!*@ $+ $$1 $+ $iif($network == Undernet, .users.undernet.org, .users.quakenet.org) }
}
alias modecheck {
  if ($nick == $me) { return }
  if ($2 != $null) {
    var %modes = $2
    var %modes2 = $gettok($chan($1).mode, 1, 32)
  }
  else {
    var %modes = $gettok($chan($1).mode, 1, 32)
    var %modes2 = %modes
  }
  if ($pos($1, /) == $null) {
    var %netchan = $network $+ / $+ $1
  }
  else {
    var %netchan = $1
  }
  var %xmode +
  if (i isincs %modes && i isincs %modes2) {
    if (!$atmodeallowed(%netchan,i)) {
      if ($regex($hget(lflagtab, $1), [m-n]) && !$hget(temp, noclear. $+ $1)) {
        msg L clearinvite $1
        hadd -mz temp noclear. $+ $1 30
      }
      pushmode $1 -i
      var %xmode = %xmode $+ i
    }
  }
  if (l isincs %modes && l isincs %modes2) {
    if (!$atmodeallowed(%netchan,l)) {
      pushmode $1 -l
      var %xmode = %xmode $+ l
    }
  }
  if (r isincs %modes && r isincs %modes2) {
    if (!$atmodeallowed(%netchan,r)) {
      pushmode $1 -r
      var %xmode = %xmode $+ r
    }
  }
  if (m isincs %modes && m isincs %modes2) {
    if (!$atmodeallowed(%netchan,m)) {
      pushmode $1 -m
      var %xmode = %xmode $+ m
    }
  }
  if (k isincs %modes && k isincs %modes2) {
    if (!$atmodeallowed(%netchan,k)) {
      pushmode $1 -k $chan($1).key
      var %xmode = %xmode $+ k
    }
  }
  if (($network == QuakeNet) && ($nick == L || $nick == Q)) { return }
  if (%xmode != + && $nick != $null) {
    if (!$atmodeallowed(%netchan, p)) {
      blacklist.add $address($nick, 3) $trans(ForbiddenModes, %xmode, $1)
    }
    if (!$atmodeallowed(%netchan, b)) {
      xbankick $chan $nick $true $trans(ForbiddenModes, %xmode, $1)
    }
  }
}
alias atakeset {
  if ($1 == $null) {
    linesep
    xecho Syntax: /atakeset <chan> <modes>
    xecho Purpose: sets which <modes> should not be allowed on <chan> (can be one or more of +iklrm)
    xecho Note: use p as a mode in <modes> to enable punishment.
    return
  }
  if ($2 != $null) {
    if ($pos($1, /) == $null) {
      hadd -m atake $network $+ / $+ $$1 $$2
    }
    else {
      hadd -m atake $$1-
    }
    hsave -o atake atake.hash
  }
  else {
    xecho $1 -> no + $+ $hget(atake,$$1)
  }
}
alias atmodeallowed {
  if ($pos($hget(atake,$1),$2) != $null) { return $false }
  return $true
}
dialog -l modloader {
  title shroudIRC: $trans(Modules)
  size -1 -1 260 149
  option dbu
  icon data\sircsmall.ico, 0
  box $trans(Modules), 1, 3 3 254 127
  button $trans(Load), 2, 3 133 37 12
  button $trans(Unload), 3, 43 133 37 12
  button $trans(OK), 4, 220 133 37 12, ok
  list 5, 7 11 246 114, size
}
alias modloader { if (!$dialog(modloader)) { dialog -mv modloader modloader } }
alias updmodlstg {
  var %sel = $gettok($gettok($did(5).seltext, 6, 32), 1, 9)
  did -r $dname 5
  var %i = 1
  module -i
  modlistgen
  while (%i <= $hget(amodules, 0).data) {
    var %f = $hget(amodules, %i).data
    did -a $dname 5 0 + 0 0 0 $hget(amodules, %i).item $+ $chr(9) $+ + 0 0 0 $readini(%f, module, NameHR) $+ $chr(9) $+ + 0 0 0 $readini(%f, module, Author) $+ $chr(9) $+ + 0 0 0 $readini(%f, module, Description) $+ $chr(9) $+ + 0 0 0 $trans($iif($hget(modules, $hget(amodules, %i).item) != $null, Yes, No))
    if ($hget(amodules, %i).item == %sel) { did -c $dname 5 $calc(%i - 1) }
    inc %i
  }
}
on *:dialog:modloader:*:*:{
  if ($devent == init) {
    mdxdll SetMircVersion $version
    mdxdll MarkDialog $dname $dialog($dname).hwnd
    mdxdll SetControlMDX $dname 5 ListView report showsel single rowselect > mdx\views.mdx
    did -i $dname 5 1 headerdims 0 110 90 190 75
    did -i $dname 5 1 headertext + 0 ID $+ $chr(9) $+ + 0 $trans(MODNameHR) $+ $chr(9) $+ + 0 $trans(MODAuthor) $+ $chr(9) $+ + 0 $trans(MODDesc) $+ $chr(9) $+ + 0 $trans(MODLoaded)
    updmodlstg
  }
  if ($devent == sclick) {
    if ($did == 2) {
      module -a $gettok($gettok($did(5).seltext, 6, 32), 1, 9)
      updmodlstg
    }
    if ($did == 3) {
      module -r $gettok($gettok($did(5).seltext, 6, 32), 1, 9)
      updmodlstg
    }
  }
}
alias mod2.init {
  module.rehash
  module -i  
}
alias mod.init {
  xhmake modules
  xhmake amodules
  xhmake modscripts
  if (!$exists($mircdir $+ modules)) { mkdir $shortfn($mircdir) $+ modules }
  xhload modules modules.hash
  xhload modscripts modules\modscripts.hash
  xasync mod2.init
  :error
  reseterror
}
alias -l idfrommod {
  return $readini($1-, module, Name)
}
alias -l modfromid {
  return $hget(modules, $1-)
}
alias modlistgen {
  hfree amodules
  xhmake amodules
  xnull $findfile($mircdir $+ \modules, *.pkd, 0, hadd -m amodules $idfrommod($1-) $1-)
}
alias -l module.internalload {
  if (!$exists($1-)) { return }
  .load -rs modules\ $+ $nopath($left($nofile($1-),-1)) $+ \ $+ $readini($1-, module, Script)
  hadd -m modscripts $nopath($readini($1-, module, Script))
  hsave -o modscripts modules\modscripts.hash
}
alias -l module.flushscripts {
  var %i = 1
  while (%i <= $hget(modscripts, 0).data) {
    if ($script($hget(modscripts, %i).item)) { .unload -rs $hget(modscripts, %i).item }
    inc %i
  }
  hfree modscripts
  xhmake modscripts
  hsave -o modscripts modules\modscripts.hash
}
alias module.rehash {
  module.flushscripts
  var %i = 1
  modlistgen
  while (%i <= $hget(modules, 0).data) {
    module.internalload $hget(amodules, $hget(modules, %i).item)
    inc %i
  }
}
alias -l mod.inst {
  unzipdll Unzip -odS zipsig $shortfn($1-) " $+ $shortfn($mircdir) $+ modules"
  if (!$exists($mircdir $+ modules\installed)) { mkdir $shortfn($mircdir) $+ modules\installed }
  if ($exists($shortfn($mircdir $+ modules\installed\ $+ $nopath($1-)))) { .remove $shortfn($mircdir $+ modules\installed\ $+ $nopath($1-)) }
  .rename $shortfn($1-) $shortfn($mircdir) $+ modules\installed\ $+ $nopath($1-)
}
alias module {
  if ($1 == -a) {
    modlistgen
    if ($hget(amodules, $2) != $null) {
      if ($readini($hget(amodules, $2), module, RegPL) > $shroudget(patchlevel)) { xecho you need a newer version of shroudIRC to load this module | return }
      hadd -m modules $2 1
      hsave modules modules.hash
      xecho loaded $2
      module.rehash
      return
    }
    else { xecho cannot find module ' $+ $2 $+ ' | return }
  }
  if ($1 == -r) {
    hdel modules $2 1
    hsave modules modules.hash
    xecho unloaded $2
    module.rehash
    return
  }
  if ($1 == -l) { module.rehash | xecho reloaded modules | return }
  if ($1 == -i) {
    var %f = $findfile($mircdir $+ \modules, *.pkz, 0, 0, mod.inst $1-)
    if (%f) { xecho unpacked all new zip files }
    return
  }
  if ($1 == -u && $2 != $null) { xecho not yet available | return }
  linesep
  xecho Syntax:
  xecho Reload: /module -l
  xecho Install: /module -i
  xecho Add: /module -a <id>
  xecho Remove: /module -r <id>
  linesep
  xecho loaded modules:
  var %i = 1
  while (%i <= $hget(modules, 0).data) {
    xecho $hget(modules, %i).item
    inc %i
  }
  linesep
  xecho available modules:
  xnull $findfile($mircdir $+ \modules, *.pkd, 0, xecho $idfrommod($1-))
}
alias modmenu {
  var %i = 1
  var %x = 1
  var %v = 1
  while (%i <= $hget(modules, 0).data) {
    var %d = 1
    while ($true) {
      xnull
      var %cmd = $readini($hget(amodules, $hget(modules, %i).item), module, SubmenuAlias)
      if (%cmd != $null) { %cmd %d }
      else { xnull }
      if ($result == $null) { break }
      if (%v == $1) { return $result }
      inc %d
      inc %v
    }
    if (%v == $1) { return - }
    inc %v
    inc %i
  }
  return $null
}
alias -l simsplit {
  hadd -mu3600 netsplit. $+ $cid $address($1, 5) #av
  kick #av $1
  .timershowsplits 1 3 showsplits
  .signal -n netsplitone $nick
}
alias servopcheck {
  if ($hget(netjoin. $+ $cid, $1) || $hget(splitted. $+ $cid, $1)) {
    haltdef
  }
}
alias showsplits {
  if ($hget(netsplit. $+ $cid)) {
    var %d = 1
    while ($chan(%d)) {
      var %e = 1, %c = $v1, %n
      while (%e <= $hget(netsplit. $+ $cid, 0).item) {
        if ($istok($hget(netsplit. $+ $cid, %e).data, %c, 32)) {
          var %n = $addtok(%n, $gettok($hget(netsplit. $+ $cid, %e).item, 1, 33), 32))
        }
        inc %e
      }
      if (%n) {
        .signal -n netsplitchan %c %n
        echo -st (signal) netsplitchan %c %n
        if (!$sihalted) { kte_echo %c Netsplit: $replace(%n, $chr(32), $chr(44) $+ $chr(32)) }
      }
      inc %d
    }
    var %d = 1
    while (%d <= $hget(netsplit. $+ $cid, 0).item) {
      hadd -mu3600 splitted. $+ $cid $hget(netsplit. $+ $cid, %d).item $hget(netsplit. $+ $cid, %d).data
      inc %d
    }
    .timerdiscardsplitted 1 3600 discardsplitted
  }
}
alias showjoins {
  if ($hget(netjoin. $+ $cid)) {
    var %d = 1
    while ($chan(%d)) {
      var %e = 1, %c = $v1, %n
      while (%e <= $hget(netjoin. $+ $cid, 0).item) {
        if ($istok($hget(netjoin. $+ $cid, %e).data, %c, 32)) {
          var %n = $addtok(%n, $hget(netjoin. $+ $cid, %e).item, 32))
        }
        inc %e
      }
      if (%n) {
        .signal -n netburstchan %c %n
        echo -st (signal) netburstchan %c %n
        if (!$sihalted) { kte_echo %c Netjoin: $replace(%n, $chr(32), $chr(44) $+ $chr(32)) }
        var %p = %p %n
      }
      inc %d
    }
  }
  var %d = 1
  echo -st returned: %p
  while (%d <= $numtok(%p, 32)) {
    echo -st killing $gettok(%p, %d, 32)
    hdel netjoin. $+ $cid $gettok(%p, %d, 32)
    hdel splitted. $+ $cid $gettok(%p, %d, 32)
    inc %d
  }
}
alias discardsplitted {
  if ($hget(splitted. $+ $cid)) {
    hfree $v1
  }
}
alias split.init {
  xhmake netsplit
  xhload netsplit netsplit.hash
}
alias netsplit {
  if (a $+ $1 == a) {
    var %cnt = $hget(netsplit,0).item
    var %i = 1
    var %jback 1
    goto syntax
    :jback
    linesep
    xecho current networks:
    while (%i <= %cnt) {
      xecho $hget(netsplit,%i).item
      inc %i
    }
    return
  }
  if ($1 == -l) {
    xhload netsplit netsplit.hash
    xecho networks reloaded
    return
  }
  if ($1 == -r && a $+ $2 != a) {
    hdel netsplit $$2
    hsave -o netsplit netsplit.hash
    xecho $$2 removed
    return
  }
  if ($1 == -a && a $+ $2 != a) {
    hadd -m netsplit $$2 1
    hsave -o netsplit netsplit.hash
    xecho $$2 added
    return
  }
  :syntax
  linesep
  xecho Syntax:
  xecho   add: /netsplit -a <network>
  xecho   remove: /netsplit -r <network>
  xecho   view: /netsplit
  xecho   reload from disk: /netsplit -l
  if (%jback) { goto jback }
}
alias isnetsplitnet {
  return $iif($hfind(netsplit, $network), $true, $false)
}
alias splitinfo {
  var %d = 1, %t = splitted. $+ $cid
  while (%d <= $hget(%t, 0).item) {
    if ($istok($hget(%t, %d).data,$active,32) || $1 == all) {
      var %a = $addtok(%a, $gettok($hget(%t, %d).item, 1, 33), 44)
    }
    inc %d
  }
  echo -a $iif(%a, splitted nicks: $replace(%a,$chr(44), $+($chr(44),$chr(32))), no information is available.)
}
alias sinickserv.init {
  if (!%nkey) { set %nkey $randqkey }
  xhmake ghosts
  xhmake nickserv
  xhload nickserv nickserv.hash
  :error
  reseterror
}
alias newauthfile {
  var %c = 8
  var %i = 1
  while (%i <= %c) {
    var %ret = %ret $+ $rand(a,z)
    inc %i
  }
  var %file = $shortfn($mircdir) $+ data\ $+ %ret $+ .dat
  if ($exists(%file)) { return $newauthfile }
  return %file
}
alias sinsauth { return $dll(shroud.dll,nsauth,$$1 %nkey) }
alias sisetnsauth { return $dll(shroud.dll, setnsauth,$$1-2 %nkey) }
alias sinsghost { return $dll(shroud.dll,nsghost,$$1 %nkey) }
alias performc.init {
  xhmake performchans
  xhmake performcnet
  xhmake performckey
  xhload performchans performc.hash
  xhload performcnet performcnet.hash
  xhload performckey performckey.hash
  :error
  reseterror
}
alias doperformc {
  var %cnt $hget(performchans,0).item
  var %i = 1
  .timerauth $+ $cid off
  while (%i <= %cnt) {
    var %net = $hget(performcnet,$hget(performchans,%i).item)
    if (%net == $null || $network == %net) {
      join $hget(performchans,%i).item $hget(performckey, $hget(performchans,%i).item))
    }
    inc %i
  }
  pfchelper
}
alias -l pfchelper {
  var %cnt = $chan(0)
  var %i = 1
  while (%i <= %cnt) {
    if ($hfind(performchans, $chan(%i)) == $null && $me !ison $chan(%i)) {
      echo $color(info) -t $chan(%i) * Press Shift-F11 to rejoin this channel
    }
    inc %i
  }
}
alias performc {
  if (a $+ $1 == a) {
    var %cnt = $hget(performchans,0).item
    var %i = 1
    var %jback 1
    goto syntax
    :jback
    linesep
    xecho current channels:
    while (%i <= %cnt) {
      var %net = $hget(performcnet,$hget(performchans,%i).item)
      var %key = $hget(performckey,$hget(performchans,%i).item)
      xecho $hget(performchans,%i).item $iif(%net != $null,(net: %net $+ $iif(%key != $null, $chr(44) key: %key) $+ ), $null)
      inc %i
    }
    return
  }
  if ($1 == -l) {
    xhload performchans performc.hash
    xhload performcnet performcnet.hash
    xecho channels reloaded
    return
  }
  if ($1 == -r && a $+ $2 != a) {
    hdel performchans $$2
    hdel performcnet $$2
    hdel performckey $$2
    hsave -o performchans performc.hash
    hsave -o performcnet performcnet.hash
    hsave -o performckey performckey.hash
    xecho $$2 removed
    return
  }
  if ($1 == -a && a $+ $2 != a) {
    hadd -m performchans $$2
    hadd -m performcnet $$2 $3
    hadd -m performckey $$2 $4
    hsave -o performchans performc.hash
    hsave -o performcnet performcnet.hash
    hsave -o performckey performckey.hash
    xecho $$2 added
    return
  }
  :syntax
  linesep
  xecho Syntax:
  xecho   add: /performc -a <channel> [<network> [<key>]]
  xecho   remove: /performc -r <channel>
  xecho   view: /performc
  xecho   reload from disk: /performc -l
  if (%jback) { goto jback }
}
alias performn.init {
  xhmake performnets
  xhmake performparm
  xhload performnets performn.hash
  xhload performparm performp.hash
}
alias -l iparam {
  tokenize 32 $1-
  var %nick = $iif($1 != default && $1 != $null, $1, $mnick)
  var %email = $iif($2 != default && $2 != $null, $2, $email)
  var %name = $iif($3 != default && $3 != $null, $3-, $fullname)
  if (%nick == $null) { return $null }
  return -i %nick $anick %email %name  
}
alias doperformn {
  if (!$hget(performnets)) {
    xhmake performnets
    xhload performnets performn.hash
  }
  var %cnt = $hget(performnets,0).item
  var %i = 1
  var %once = 1
  window -x "Status Window"
  if ($hget(temp, performnonce) != $null) { return }
  hadd temp performnonce done
  while (%i <= %cnt) {
    var %net = $hget(performnets, %i).data
    var %p = $hget(performparm, %net)
    if ($scid(0) == 1 && %once == 1) {
      server %net $iparam(%p)
      var %once = 0
    }
    else {
      server -m %net $iparam(%p)
    }
    inc %i
  }
  if (%cnt == 0) { server }
}
alias net2id {
  var %cnt = $hget(performnets,0).item
  var %i = 1
  while (%i <= %cnt) {
    if ($1- == $hget(performnets,%i).data) { return $hget(performnets, %i).item }
    inc %i
  }
}
alias exchangenets {
  var %net1 = $net2id($$1)
  var %net2 = $net2id($$2)
  if (%net1 != $null && %net2 != $null) {
    hadd -m performnets %net1 $$2
    hadd -m performnets %net2 $$1
    hsave -o performnets performn.hash
  }
}
alias performn {
  if (a $+ $1 == a) {
    var %cnt $hget(performnets,0).item
    var %i = 1
    var %jback 1
    goto syntax
    :jback
    linesep
    xecho current networks:
    while (%i <= %cnt) {
      xecho $hget(performnets,%i).data $iif($hget(performparm, $hget(performnets,%i).data), ( $+ $ifmatch $+ ))
      inc %i
    }
    return
  }
  if ($1 == -l) {
    xhload performnets performn.hash
    xecho networks reloaded
    return
  }
  if ($1 == -r && a $+ $2 != a) {
    var %id = $net2id($$2)
    if (%id) {
      hdel performnets %id
      hdel performparm $2
      hsave -o performnets performn.hash
      hsave -o performparm performp.hash
      xecho $$2 removed
    }
    return
  }
  if ($1 == -a && a $+ $2 != a) {
    var %id = $iif($net2id($$2) != $null, $net2id($$2), n $+ $suid)
    hadd -m performnets %id $2
    hadd -m performparm $2 $3-
    hsave -o performnets performn.hash
    hsave -o performparm performp.hash
    xecho $$2 added
    return
  }
  :syntax
  linesep
  xecho Syntax:
  xecho   add: /performn -a <network> [<nick> [<email> [<gecos>]]]
  xecho   remove: /performn -r <network>
  xecho   view: /performn
  xecho   reload from disk: /performn -l
  if (%jback) { goto jback }
}
dialog -l pnetedit {
  title $trans(EditNetwork)
  size -1 -1 114 90
  option dbu
  icon data\sircsmall.ico, 0
  box $trans(Network), 1, 4 3 106 22
  button $trans(Ok), 2, 73 74 37 12, default ok
  button $trans(Cancel), 3, 32 74 37 12, cancel
  box $trans(UserInfo), 4, 4 27 106 44
  text $trans(Name) $+ :, 5, 8 12 25 8, right
  edit "", 6, 36 11 70 10, read autohs
  text $trans(Nick) $+ :, 7, 8 36 25 8, right
  text $trans(EMail) $+ :, 8, 8 47 25 8, right
  text $trans(Name) $+ :, 9, 8 58 25 8, right
  edit "", 10, 36 35 70 10, autohs
  edit "", 11, 36 46 70 10, autohs
  edit "", 12, 36 57 70 10, autohs
}
on *:dialog:pnetedit:*:*:{
  if ($devent == sclick && $did == 2) {
    performn -a $did(6) $iif($did(10) != $null, $ifmatch, default) $iif($did(11) != $null, $ifmatch, default) $iif($did(12) != $null, $ifmatch, default)
  }
}
alias pnetedit {
  var %id = $net2id($1)
  if (!$dialog(pnetedit) && %id != $null) {
    dialog -mav pnetedit pnetedit
    did -a pnetedit 6 $1
    var %param = $hget(performparm, $1)
    tokenize 32 %param
    if ($1 != default) { did -a pnetedit 10 $1 }
    if ($2 != default) { did -a pnetedit 11 $2 }
    if ($3 != default) { did -a pnetedit 12 $3- }
  }
}
dialog -l psypw_help {
  icon data\sircsmall.ico
  title "psyBNC Help"
  size -1 -1 164 193
  option dbu
  text "Did you know that you can specify your password in the server-options dialog?", 1, 4 4 140 16
  icon 2, 3 25 155 124, pics\psypw.bmp, 0, noborder
  text "Press Alt-O, select Connect->Servers from the treeview-box and click on Edit", 3, 3 155 157 15
  button "OK", 4, 123 175 37 12, default ok cancel
  check "Don't show again", 5, 3 177 55 10
}
on *:dialog:psypw_help:sclick:5:{
  set %nopsypwhelp $did(5).state
}
alias psypw_help { if (%nopsypwhelp != 1) { dialog -mv psypw_help psypw_help } }
alias -l pushmodeworker {
  var %h = queue. $+ $1 $+ $cid
  var %phase = 1, %v = 0
  if ($hget(%h) == $null) { return }
  if ($me !isop $1 && $me !ishop $1) {
    if ($hget(%h) != $null) { hfree %h }
    return
  }
  while (%phase <= 3) {
    var %c = 1
    while (%c <= $hget(%h, 0).item) {
      var %item = $hget(%h, %c).data
      var %md = $gettok(%item, 1, 32)
      var %pd = $gettok(%item, 2, 32)
      if (%md == -o && %pd !isop $1) { }
      elseif (%md == +o && %pd isop $1) { }
      elseif ($istok(i m n p s t r D c C N u, $remove(%md,+,-), 32) $&
        && (($left(%md,1) == + && $remove(%md,+) isin $gettok($chan($1).mode, 1, 32)) $&
        || ($left(%md,1) == - && $remove(%md,-) !isin $gettok($chan($1).mode, 1, 32)))) { }
      else {
        if ((%phase == 1 && %md == -o) || (%phase == 2 && %md == -b) || (%phase > 2 && %md != -o)) {
          var %m = %m $+ %md
          var %p = %p $gettok(%item, 2, 32)
          inc %v
        }
        if (%v != 0 && $calc(%v % $modespl) == 0 && %m != $null) {
          mode $1 %m %p
          var %m, %p, %v
        }
      }
      inc %c
    }
    inc %phase
  }
  if (%m != $null) {
    mode $1 %m %p
  }
  hfree %h
  .timerkqueue. [ $+ [ $1 ] ] 1 1 pushkickworker $1
}
alias pushmode.flush { pushmodeworker $$1 }
alias findmchange {
  var %c = 1
  while (%c <= $hget(queue. $+ $1 $+ $cid, 0).item) {
    if ($2- == $hget(queue. $+ $1 $+ $cid, %c).data) { return $true }
    inc %c
  }
  return $false
}
alias pushmode {
  if ($findmchange($1, $2, $3-)) { return }
  hadd -m queue. $+ $1 $+ $cid $suid $2-
  if ($hget(queue. $+ $1 $+ $cid $+ $cid, 0).item == $modespl) {
    pushmodeworker $1
  }
  else {
    .timerqueue. [ $+ [ $1 ] $+ [ $cid ] ] 1 0 pushmodeworker $1
  }
}
alias -l pushkickworker {
  var %h = kqueue. $+ $1 $+ $cid
  var %c = 0
  if ($hget(queue. $+ $1 $+ $cid,0).item > 0) { .timerkqueue. [ $+ [ $1 ] $+ [ $cid ] ] 1 1 pushkickworker $1 | return }
  if ($me !isop $1 && $me !ishop $1) {
    if ($hget(%h) != $null) { hfree %h }
    return
  }
  while ($hget(%h, 0).item > 0) {
    if ($gettok($hget(%h, 1).item, 1, 32) ison $1) {
      kick $1 $hget(%h, 1).item $hget(%h, 1).data
      inc %c
    }
    hdel %h $hget(%h, 1).item
    if (%c == 2) {
      .timerkqueue. [ $+ [ $1 ] $+ [ $cid ] ] 1 3 pushkickworker $1
      return
    }
  }
}
alias push.clear {
  if ($hget(kqueue. $+ $1 $+ $cid)) { hfree kqueue. $+ $1 $+ $cid }
  if ($hget(queue. $+ $1 $+ $cid)) {  hfree queue. $+ $1 $+ $cid }
}
alias pushkick {
  hadd -m kqueue. $+ $1 $+ $cid $2-
  .timerkqueue. [ $+ [ $1 ] $+ [ $cid ] ] 1 0 pushkickworker $1
}
alias qauth.init {
  if (!%qkey) { set %qkey $randqkey }
  :error
  reseterror
}
alias quserauth {
  var %qpass $?*="Q-Password?"
  if (%qpass != $null) {
    .!msg q@cserve.quakenet.org auth $1 %qpass
    .timerauth $+ $cid 1 10 doperformc
  }
  else {
    doperformc
  }
}
alias quseraskauth {
  if ($?!="Auth?" == $true) {
    siqauth
    .timerauth $+ $cid 1 10 doperformc
  }
  else {
    doperformc
  }
}
alias setqnflag {
  if (Q ison $$1) {
    !msg q@cserve.quakenet.org chanlev $$1-3
    return
  }
  if (L ison $$1) {
    !msg l@lightweight.quakenet.org chanlev $$1-3
    return
  }
  xechot NoChanService $1
}
alias randqkey {
  var %c = 20
  var %i = 1
  while (%i <= %c) {
    var %ret = %ret $+ $rand(a,z)
    inc %i
  }
  return %ret
}
alias siqgetnick {
  var %nick = $dll(shroud.dll,qgetnick,%qkey)
  if (*shroud.dll* iswm %nick || %nick == 0) { return $null }
  else { return %nick }
}
alias siispwset { return $dll(shroud.dll,qispwset,%qkey) }
alias sisetqdata { yecho sisetqdata: $shrouddll(setqdata, $1 %qkey) }
alias siqauth {
  var %val = $shrouddll(qauth, %qkey)
  if (%val) { yecho %val }
}
alias siqcauth {
  if ($1 != MD5) {
    yecho Q requested an unknown digest method .. unable to auth
    return
  }
  var %val = $shrouddll(qchallengeauth, %qkey $2)
  if (%val) { yecho %val }
}
alias saddr.init {
  dispwho addr.update
  xhmake silast
  xhload silast silast.hash
  :error
  reseterror
}
alias addr.lastnick {
  var %last = $hget(silast, $$1)
  if (%last == $null) {
    return <unknown>
  }
  else {
    return %last
  }
}
alias addr.setlast {
  if ($2) {
    hadd -m silast $1 $2
    .timersaveaddrs 1 5 hsave -o silast silast.hash
  }
}
alias addr.update {
  addr.setlast $mask($$3, 2) $$4
}
dialog -l lqhelp {
  title shroudIRC: L/Q-FLags
  size -1 -1 140 80
  option dbu
  icon data\sircsmall.ico, 0
  text "The flags shown in the L/Q-dialog are those represented by shroudIRC's internal flags array. Use /lqflags to update them.", 1, 5 5 130 30
  text "If an item is prefixed with a * that means, that chan- flag-recovery is disabled for this chan. Doubleclick on an item to toggle this state.", 2, 5 35 130 30
  button "Ok", 6, 90 60 45 15, ok
}
dialog -l sisettings {
  title shroudIRC: $trans(Settings)
  size -1 -1 304 195
  option dbu
  icon data\sircsmall.ico, 0
  tab "shroudIRC Splash", 146, -51 -44 375 249
  list 147, 88 4 210 171, tab 146 size
  text "", 59, 89 179 167 8, disable tab 146
  tab "shroudIRC", 1
  check $trans(psyBNCNotices), 3, 91 7 200 10, tab 1
  check $trans(RemoveBans), 5, 91 20 200 10, tab 1
  check $trans(BalloonSystem), 6, 91 34 200 10, tab 1
  check $trans(CheckIpOnStartup), 7, 91 47 200 10, tab 1
  text $trans(Birthday), 14, 96 116 53 8, tab 1 right
  edit $shroudget(birthday), 48, 153 115 70 10, tab 1 autohs
  text $trans(UsedByAge), 49, 226 116 66 8, tab 1
  check $trans(CheckPatches), 134, 91 60 200 10, tab 1
  check $trans(ShowLast), 135, 91 73 200 10, tab 1
  text $trans(BanMask), 2, 96 102 52 8, tab 1 right
  combo 165, 153 100 98 65, tab 1 size drop
  check $trans(CustomTB), 181, 91 86 200 10, tab 1
  tab "Away", 8
  text $trans(AwayNick), 9, 92 8 65 8, tab 8 right
  edit $shroudget(awnick), 10, 160 7 82 10, tab 8 autohs
  check $trans(ChannelSpam), 11, 92 40 182 9, tab 8
  text $trans(DefaultAway), 12, 92 23 65 8, tab 8 right
  edit $shroudget(awmsg), 13, 160 22 135 10, tab 8 autohs
  box $trans(Exceptions), 60, 91 57 203 100, tab 8
  list 61, 95 78 195 59, tab 8 size
  button $trans(Add), 62, 96 140 37 12, tab 8
  button $trans(Delete), 140, 136 140 37 12, tab 8
  text $trans(NoNickChange), 144, 96 67 194 8, tab 8
  tab "Blowfish", 15
  box $trans(Keys), 43, 92 8 207 123, tab 15
  list 44, 97 17 197 95, tab 15 size extsel
  button $trans(Add), 46, 217 114 37 12, tab 15
  button $trans(Delete), 45, 257 114 37 12, tab 15
  text $trans(BlowfishHelp), 47, 91 135 207 25, tab 15
  check $trans(HideForged), 176, 98 115 116 10, tab 15
  text $trans(ToggleHelp), 178, 91 164 159 8, tab 15
  tab "MP3", 16
  box $trans(CustomColors), 33, 88 4 140 110, tab 16
  list 34, 93 13 131 80, tab 16 sort size hsbar
  button $trans(Add), 35, 93 96 42 12, tab 16
  button "Add (custom)", 36, 137 96 42 12, tab 16
  button $trans(Delete), 37, 181 96 42 12, tab 16
  box $trans(Options), 32, 89 116 211 49, tab 16
  check $trans(ShowGenre), 27, 94 124 70 10, tab 16
  check $trans(ShowAlbum), 28, 94 136 70 10, tab 16
  check $trans(ShowYear), 29, 94 148 70 10, tab 16
  check $trans(ShowLength), 30, 168 124 68 10, tab 16
  check $trans(ShowStatus), 31, 168 136 70 10, tab 16
  check $trans(EnableTrigger), 161, 168 148 70 10, tab 16
  text "Prefix:", 38, 235 13 50 8, tab 16
  edit $shroudget(smp3prefix), 39, 235 23 60 10, tab 16 autohs
  text "Trigger:", 40, 235 37 50 8, tab 16
  edit $shroudget(smp3trigger), 41, 235 47 60 10, tab 16 autohs
  button $trans(SkinEditor), 24, 234 99 61 12, tab 16
  text $trans(StatusText), 25, 235 61 50 8, tab 16
  edit $shroudget(smp3status), 42, 235 71 60 10, tab 16 autohs
  box $trans(Options) (2), 26, 231 4 67 110, tab 16
  box "", 104, 231 80 67 4, tab 16
  button $trans(SkinViewer), 105, 234 86 61 12, tab 16
  check $trans(ShowUrl), 177, 238 137 58 10, tab 16
  check $trans(EnableInfoTrigger), 4, 238 124 58 10, tab 16
  tab "Fserve", 17
  check $trans(EnableFServe), 18, 92 8 205 10, tab 17
  text $trans(FServeTrigger), 20, 92 25 70 8, tab 17 right
  edit $shroudget(fstrigger), 21, 164 24 70 10, tab 17
  text $trans(FServeDir), 22, 92 40 70 8, tab 17 right
  edit $shroudget(fsdir), 23, 164 39 135 10, tab 17
  button "...", 222, 282 52 17 12, tab 17
  tab "Q-Auth", 50
  text $trans(QAuthHelp), 51, 90 136 207 29, tab 50
  text "Q-Authname:", 52, 92 7 52 8, tab 50 right
  text "Q-Password:", 53, 92 21 52 8, tab 50 right
  edit "", 55, 148 7 85 10, tab 50 autohs
  edit "", 56, 148 21 85 10, tab 50 pass autohs
  check $trans(AskPwConnect), 54, 91 37 200 10, tab 50
  check $trans(SetXMode), 57, 91 50 200 10, tab 50
  check $trans(SetRMode), 58, 91 64 200 10, tab 50
  check $trans(AskBeforePwSend), 63, 91 77 200 10, tab 50
  button $trans(AuthNow), 64, 251 7 47 12, tab 50
  check $trans(QChallengeAuth), 182, 91 90 200 10, tab 50
  tab "NickServ identify", 200
  list 193, 92 4 205 107, tab 200 size extsel
  button $trans(New), 190, 93 114 43 12, tab 200
  button $trans(Delete), 189, 140 114 43 12, tab 200
  box $trans(Options), 159, 93 130 204 34, tab 200
  check $trans(AutoGhost), 160, 98 141 194 10, tab 200
  tab "Hidden channels", 65
  list 66, 96 13 196 88, tab 65 size
  button $trans(Add), 68, 215 105 37 12, tab 65
  button $trans(Delete), 67, 255 105 37 12, tab 65
  box $trans(Channels), 69, 92 5 204 117, tab 65
  text $trans(ChanHideHelp), 70, 92 127 204 33, tab 65
  tab "Perform", 71
  box $trans(Channels), 72, 92 5 204 117, tab 71
  list 73, 96 13 196 88, tab 71 size extsel
  text $trans(AddChansHere), 74, 92 127 204 33, tab 71
  button $trans(Add), 75, 215 105 37 12, tab 71
  button $trans(Delete), 76, 255 105 37 12, tab 71
  text $trans(ToggleHelp), 180, 91 164 159 8, tab 71
  tab "F-keys", 77
  text "F2:", 78, 92 8 7 10, tab 77
  text "Strg+F2:", 80, 191 8 25 10, tab 77
  text "F3:", 81, 92 21 7 10, tab 77
  text "Strg+F3:", 84, 191 21 25 10, tab 77
  text "F4:", 85, 92 34 7 10, tab 77
  edit $fkeysv(f4), 86, 103 33 80 10, tab 77 multi autohs
  text "Strg+F4:", 89, 191 34 25 10, tab 77
  text "F5:", 90, 92 47 7 10, tab 77
  edit $fkeysv(f5), 91, 103 46 80 10, tab 77 multi autohs
  text "Strg+F5:", 94, 191 47 25 10, tab 77
  edit $fkeysv(cf5), 95, 216 46 80 10, tab 77 multi autohs
  text "F6:", 96, 92 60 7 10, tab 77
  edit $fkeysv(f6), 97, 103 59 80 10, tab 77 multi autohs
  text "Strg+F6:", 100, 191 60 25 10, tab 77
  edit $fkeysv(cf6), 101, 216 59 80 10, tab 77 multi autohs
  text "F7:", 102, 92 73 7 10, tab 77
  edit $fkeysv(f7), 103, 103 72 80 10, tab 77 multi autohs
  text "Strg+F7:", 106, 191 73 25 10, tab 77
  edit $fkeysv(cf7), 107, 216 72 80 10, tab 77 multi autohs
  text "F8:", 108, 92 86 7 10, tab 77
  edit $fkeysv(f8), 109, 103 85 80 10, tab 77 multi autohs
  text "Strg+F8:", 112, 191 86 25 10, tab 77
  edit $fkeysv(cf8), 113, 216 85 80 10, tab 77 multi autohs
  text "F9:", 114, 92 99 7 10, tab 77
  edit $fkeysv(f9), 115, 103 98 80 10, tab 77 multi autohs
  text "Strg+F9:", 118, 191 99 25 10, tab 77
  edit $fkeysv(cf9), 119, 216 98 80 10, tab 77 multi autohs
  text "F10:", 120, 92 112 10 10, tab 77
  edit $fkeysv(f10), 121, 103 111 80 10, tab 77 multi autohs
  text "Strg+F10:", 124, 191 112 25 10, tab 77
  edit $fkeysv(cf10), 125, 216 111 80 10, tab 77 multi autohs
  text "F11:", 126, 92 125 10 10, tab 77
  edit $fkeysv(f11), 127, 103 124 80 10, tab 77 multi autohs
  text "Strg+F11:", 130, 191 125 25 10, tab 77
  edit $fkeysv(cf11), 131, 216 124 80 10, tab 77 multi autohs
  text "F12:", 132, 92 138 10 10, tab 77
  edit $fkeysv(f12), 133, 103 137 80 10, tab 77 multi autohs
  text "Strg+F12:", 136, 191 138 25 10, tab 77
  edit $fkeysv(cf12), 137, 216 137 80 10, tab 77 multi autohs
  edit $fkeysv(f2), 138, 103 7 80 10, tab 77 multi autohs
  edit $fkeysv(f3), 139, 103 20 80 10, tab 77 multi autohs
  edit $fkeysv(cf2), 141, 216 7 80 10, tab 77 multi autohs
  edit $fkeysv(cf3), 142, 216 20 80 10, tab 77 multi autohs
  edit $fkeysv(cf4), 143, 216 33 80 10, tab 77 multi autohs
  text $trans(AssignFKeys), 79, 92 154 204 8, tab 77
  tab "L/Q-Flags", 82
  box "Flags (Q)", 83, 92 7 185 77, tab 82
  box "Flags (L)", 87, 92 89 185 77, tab 82
  list 88, 96 15 178 66, tab 82 size extsel
  list 92, 96 97 178 66, tab 82 size extsel
  button "?", 93, 282 10 15 12, tab 82
  button "!", 110, 282 25 15 12, tab 82
  tab "Networks", 148
  box $trans(Networks), 150, 91 5 206 154, tab 148
  list 151, 95 92 158 58, tab 148 size
  button $trans(Delete), 154, 256 92 37 12, tab 148
  button $trans(Add), 155, 256 16 37 12, tab 148
  list 153, 95 16 158 58, tab 148 sort size
  button $trans(Down), 149, 256 137 37 12, tab 148
  button $trans(Up), 152, 256 123 37 12, tab 148
  text $trans(PerformedNets), 156, 96 80 157 8, tab 148
  button $trans(Edit), 179, 256 106 37 12, tab 148
  tab "shroudIRC splash", 157
  icon 158, 89 4 206 158,  data\logo2_t.jpg, 0, tab 157 noborder
  tab "Language", 111
  text "shroudIRC is multilingual! Please select your preferred language from the list below. Changes will be applied immediatelly.", 116, 90 5 209 22, tab 111
  box "Available languages", 117, 90 30 209 106, tab 111
  button "Load", 122, 257 118 37 12, tab 111
  list 123, 94 39 201 76, tab 111 sort size extsel
  tab "Filter", 208
  box $trans(FilteredWords), 128, 92 8 204 114, tab 208
  list 129, 96 16 196 85, tab 208 size
  button $trans(Add), 162, 215 104 37 12, tab 208
  button $trans(Delete), 163, 255 104 37 12, tab 208
  text $trans(AddFiltersHere), 164, 92 127 204 33, tab 208
  tab "X-Auth", 166
  text "X-Authname:", 167, 92 7 52 8, tab 166 right
  edit "", 168, 148 7 85 10, tab 166 autohs
  edit "", 169, 148 21 85 10, tab 166 pass autohs
  text "X-Password:", 170, 92 21 52 8, tab 166 right
  button $trans(AuthNow), 171, 251 7 47 12, tab 166
  check $trans(AskPwConnect), 172, 91 37 200 10, tab 166
  check $trans(SetXMode), 173, 91 50 200 10, tab 166
  check $trans(AskBeforePwSend), 174, 91 63 200 10, tab 166
  text $trans(XAuthHelp), 175, 90 136 207 29, tab 166
  tab "AuthServ identify", 183
  list 185, 92 4 205 107, tab 183 size extsel
  button $trans(New), 186, 93 114 43 12, tab 183
  button $trans(Delete), 187, 140 114 43 12, tab 183
  tab "Netsplit", 184
  list 188, 94 4 205 107, tab 184 size extsel
  button $trans(New), 191, 95 114 43 12, tab 184
  button $trans(Delete), 192, 142 114 43 12, tab 184
  text $trans(NetsplitWhatIs), 194, 94 130 205 29, tab 184
  button $trans(Ok), 19, 261 178 37 12, default ok
  list 145, 4 4 82 185, size
}
alias -l updmp3col {
  var %cnt $hget(smp3colors,0).item
  var %i = 1
  did -r $dname 34
  while (%i <= %cnt) {
    did -a $dname 34 $replace($hget(smp3colors,%i).item,~,$chr(32)) -> $hget(smp3colors,%i).data
    inc %i
  }
}
alias -l updbfchans {
  var %cnt $hget(bfchans,0).item
  var %i = 1
  var %sel = $gettok($gettok($did($1,44).seltext, 6, 32), 1, 9)
  did -r $1 44
  while (%i <= %cnt) {
    did -a $1 44 0 + 0 0 0 $hget(bfchans,%i).item $+ $chr(9) $+ + 0 0 0 $hget(bfchans,%i).data $+ $chr(9) $+ + 0 0 0 $trans($iif($hget(bfautochans, $hget(bfchans,%i).item) != $null, Yes, No))
    if ($hget(bfchans,%i).item == %sel) { did -c $1 44 $calc(%i + 1) }
    inc %i
  }
}
alias -l updhchanlist {
  var %cnt $hget(chanhide,0).item
  var %i = 1
  did -r $dname 66
  while (%i <= %cnt) {
    did -a $dname 66 $hget(chanhide,%i).item
    inc %i
  }
}
alias -l updfilterlist {
  var %cnt $hget(wordfilter,0).item
  var %i = 1
  did -r $dname 129
  while (%i <= %cnt) {
    did -a $dname 129 $hget(wordfilter,%i).data
    inc %i
  }
}
alias -l updpchanlist {
  var %cnt $hget(performchans,0).item
  var %i = 1
  did -r $1 73
  while (%i <= %cnt) {
    var %net = $hget(performcnet,$hget(performchans,%i).item)
    var %key = $hget(performckey,$hget(performchans,%i).item)
    if (%key == $null) { var %key = (none) }
    did -a $1 73 0 + 0 0 0 $hget(performchans,%i).item $+ $chr(9) $+ + 0 0 0 $iif(%net != $null, %net, (none)) $+ $chr(9) $+ + 0 0 0 %key
    inc %i
  }
}
alias -l updxcplist {
  var %cnt = $hget(awxcp, 0).item
  var %i = 1
  did -r $dname 61
  while (%i <= %cnt) {
    did -a $dname 61 $hget(awxcp,%i).item
    inc %i
  }
}
alias -l serverlistgen {
  var %i = 0
  xhmake networks
  var %serversini = $readini($mircdir $+ mirc.ini, files, servers)
  if (!%serversini) { var %serversini $mircdir $+ servers.ini }
  while ($true) {
    var %line = $readini(%serversini, n, servers, n $+ %i)
    inc %i
    if (!%line) { return }
    if (GROUP: !isin %line) { continue }
    var %net = $mid(%line, $calc($poscs(%line, GROUP:) + 6))
    if ($hget(networks, %net) = $null) {
      hadd networks %net
    }
  }
}
alias serverlist {
  var %dname = $iif($dname != $null, $dname, sisettings)
  did -r %dname 153
  serverlistgen
  var %i = 1
  var %cnt = $hget(networks, 0).item
  while (%i <= %cnt) {
    did -a %dname 153 $hget(networks, %i).item
    inc %i
  }
}
alias netsplitlistupd {
  var %dname = $iif($dname != $null, $dname, sisettings)
  did -r %dname 188
  var %i = 1
  var %cnt = $hget(netsplit, 0).item
  while (%i <= %cnt) {
    did -a %dname 188 $hget(netsplit, %i).item
    inc %i
  }
}
alias -l performnetslist {
  var %cnt = $hget(performnets, 0).item
  var %i = 1
  did -r $1 151
  while (%i <= %cnt) {
    did -a $1 151 $hget(performnets,%i).data
    inc %i
  }
}
alias -l listlanguages2 {
  xhmake language_t
  xhload language_t $shortfn($1-)
  did -a $dname 123 0 + 0 0 0 $hget(language_t, Language) $+ $chr(9) $+ + 0 0 0 $hget(language_t, ID_NativeName) $+ $chr(9) $+ + 0 0 0 $gettok($nopath($1-),1,46)
  if ($gettok($nopath($1-),1,46) == $shroudget(language)) { did -c $dname 123 $did($dname, 123).lines }
  hfree language_t
}
alias -l listlanguages {
  xnull $findfile($mircdir $+ data\trans,*.lang,0,listlanguages2 $1-)
}
alias updlqflagslist {
  var %cnt $hget(lflagtab,0).item
  var %i = 1
  did -r $1 92
  while (%i <= %cnt) {
    did -a $1 92 0 + 0 0 0 $hget(lflagtab,%i).item $+ $chr(9) $+ + 0 0 0 $hget(lflagtab,%i).data
    inc %i
  }
  var %cnt $hget(qflagtab,0).item
  var %i = 1
  did -r $1 88
  while (%i <= %cnt) {
    did -a $1 88 0 + 0 0 0 $hget(qflagtab,%i).item $+ $chr(9) $+ + 0 0 0 $hget(qflagtab,%i).data
    inc %i
  }
}
on *:dialog:sisettings:init:0:{
  mdxdll SetMircVersion $version
  mdxdll MarkDialog $dname $dialog($dname).hwnd
  mdxdll SetControlMDX $dname 145 TreeView haslines showsel > mdx\views.mdx
  did -i $dname 145 1 cb root
  did -a $dname 145 +fseb 0 0 0 0 0 shroudIRC
  did -i $dname 145 1 cb last
  didtok $dname 145 44 + 0 0 0 0 0 $trans(General) ,+ 0 0 0 0 0 Away,+ 0 0 0 0 0 $trans(FKeys) ,+ 0 0 0 0 0 Language/Sprache
  did -i $dname 145 1 cb up
  did -a $dname 145 +eb 0 0 0 0 0 Perform
  did -i $dname 145 1 cb last
  didtok $dname 145 44 + 0 0 0 0 0 $trans(Networks) ,+ 0 0 0 0 0 Channels,+ 0 0 0 0 0 $trans(HiddenChans)
  did -i $dname 145 1 cb up
  did -a $dname 145 +eb 0 0 0 0 0 Auth
  did -i $dname 145 1 cb last
  didtok $dname 145 44 + 0 0 0 0 0 Q (QuakeNet),+ 0 0 0 0 0 X (UnderNet),+ 0 0 0 0 0 NickServ,+ 0 0 0 0 0 AuthServ
  did -i $dname 145 1 cb up
  did -a $dname 145 +eb 0 0 0 0 0 Extras
  did -i $dname 145 1 cb last
  didtok $dname 145 44 + 0 0 0 0 0 Blowfish,+ 0 0 0 0 0 MP3,+ 0 0 0 0 0 Fserve,+ 0 0 0 0 0 L/Q-Flags,+ 0 0 0 0 0 Filter,+ 0 0 0 0 0 Netsplit
  did -i $dname 145 1 cb up
  did -f $dname 145
  mdxdll SetControlMDX $dname 44 ListView report showsel single rowselect > mdx\views.mdx
  did -i $dname 44 1 headerdims 130 180 40
  did -i $dname 44 1 headertext + 0 $trans(Target) $+ $chr(9) $+ + 0 $trans(Key) $+ $chr(9) $+ + 0 $trans(AutoEnc)
  mdxdll SetControlMDX $dname 88 ListView report showsel single rowselect > mdx\views.mdx
  did -i $dname 88 1 headerdims 150 150
  did -i $dname 88 1 headertext + 0 $trans(Channel) $+ $chr(9) $+ + 0 Flags
  mdxdll SetControlMDX $dname 92 ListView report showsel single rowselect > mdx\views.mdx
  did -i $dname 92 1 headerdims 150 150
  did -i $dname 92 1 headertext + 0 $trans(Channel) $+ $chr(9) $+ + 0 Flags
  mdxdll SetControlMDX $dname 193 ListView report showsel single rowselect > mdx\views.mdx
  did -i $dname 193 1 headerdims 200 200
  did -i $dname 193 1 headertext + 0 $trans(Network) $+ $chr(9) $+ + 0 Nick
  mdxdll SetControlMDX $dname 185 ListView report showsel single rowselect > mdx\views.mdx
  did -i $dname 185 1 headerdims 200 200
  did -i $dname 185 1 headertext + 0 $trans(Network) $+ $chr(9) $+ + 0 Nick
  mdxdll SetControlMDX $dname 73 ListView report showsel single rowselect > mdx\views.mdx
  did -i $dname 73 1 headerdims 120 150 60
  did -i $dname 73 1 headertext + 0 $trans(Channel) $+ $chr(9) $+ + 0 $trans(Network) $+ $chr(9) $+ + 0 Key
  mdxdll SetControlMDX $dname 123 ListView report showsel single rowselect > mdx\views.mdx
  did -i $dname 123 1 headerdims 120 120 80
  did -i $dname 123 1 headertext + 0 Name $+ $chr(9) $+ + 0 Native Name $+ $chr(9) $+ + 0 ID
  did -a $dname 59 shroudIRC $shroudget(version) ( $+ release $shroudget(release) $+ , build $shroudget(patchlevel) $+ )
  htmldll attach $htmldll(item,$dialog(sisettings).hwnd id:147)
  var %file = $shortfn($mircdir) $+ data\ $+ $shroudget(language) $+ \setup.html
  if (!$exists(%file)) {
    var %file = $shortfn($mircdir) $+ data\1033\setup.html
  }
  htmldll navigate $+(file://,%file)
  mdxdll SetBorderStyle $dname 147
  listlanguages
  xasync serverlist
  performnetslist $dname
  if ($shroudget(autoupdate) == on) { did -c $dname 134 }
  if ($shroudget(disabletb) != on) { did -c $dname 181 }
  updbfchans $dname
  if ($shroudget(bhideforged) == on) { did -c $dname 176 }
  updmp3col
  if ($shroudget(smp3genre) == on) { did -c $dname 27 }
  if ($shroudget(smp3album) == on) { did -c $dname 28 }
  if ($shroudget(smp3year) == on) { did -c $dname 29 }
  if ($shroudget(smp3length) == on) { did -c $dname 30 }
  if ($shroudget(smp3showurl) == on) { did -c $dname 177 }
  if ($shroudget(smp3showstatus) == on) { did -c $dname 31 }
  else { did -b $dname 42 }
  if ($shroudget(smp3triggeract) == on) { did -c $dname 161 }
  if ($shroudget(smp3infotrigact) == on) { did -c $dname 4 }
  if ($shroudget(awbcast) == on) { did -c sisettings 11 }
  updxcplist
  if ($shroudget(fsenabled) == on) { did -c $dname 18 }
  if ($shroudget(psyconv) == on) { did -c $dname 3 }
  if ($shroudget(unbanself) == on) { did -c $dname 5 }
  if ($shroudget(balloon) == on) { did -c $dname 6 }
  if ($shroudget(docheckip) == on) { did -c $dname 7 }
  if ($shroudget(silast) == on) { did -c $dname 135 }
  var %qn = $siqgetnick
  if ($succeeded(%qn)) { did -a $dname 55 %qn }
  if ($succeeded($siispwset)) { did -a $dname 56 xxx }
  if ($shroudget(qsetx) == on) { did -c $dname 57 }
  if ($shroudget(qsetr) == on) { did -c $dname 58 }
  if ($shroudget(qask) == on) { did -c $dname 63 }
  if ($shroudget(qchallenge) == on) { did -c $dname 182 }
  if ($shroudget(qaskpw) == on) {
    did -c $dname 54
    did -r $dname 56
    did -m $dname 56
    sisetqdata $did(55).text $+ $chr(124)
  }
  if ($did(55).text == $null || $did(56).text == $null) { did -b $dname 182 }
  else { did -e $dname 182 }
  if ($xcheckdll) {
    var %xn = $sixgetnick
    if ($succeeded(%xn)) { did -a $dname 168 %xn }
    if ($succeeded($sixispwset)) { did -a $dname 169 xxx }
    if ($shroudget(xsetx) == on) { did -c $dname 173 }
    if ($shroudget(xask) == on) { did -c $dname 174 }
    if ($shroudget(xaskpw) == on) {
      did -c $dname 172
      did -r $dname 169
      did -m $dname 169
      sisetxdata $did(55).text $+ $chr(124)
    }
  }
  else {
    xdisableoptions
  }
  updnetlist
  if ($shroudget(autoghost)) { did -c $dname 160 }
  updasnetlist
  updhchanlist
  updpchanlist $dname
  updlqflagslist $dname
  updfilterlist
  var %c = 0
  while (%c <= 9) {
    did -a $dname 165 ( $+ %c $+ ) $mask(nick!ident@dial-F23175.host.org, %c)
    inc %c
  }
  if ($shroudget(banmask) != $null) {
    if ($shroudget(banmask) > 9) {
      did -a $dname 165 ( $+ $shroudget(banmask) $+ ) $mask(nick!ident@dial-F23175.host.org, $shroudget(banmask))
      did -c $dname 165 11
    }
    else {
      did -c $dname 165 $calc($shroudget(banmask) + 1)
    }
  }
  else {
    if (%banstandard > 9) {
      did -a $dname 165 ( $+ %banstandard $+ ) $mask(nick!ident@dial-F23175.host.org, %banstandard)
      did -c $dname 165 11
    }
    else {
      did -c $dname 165 $calc(%banstandard + 1)
    }
  }
  netsplitlistupd
}
on *:dialog:sisettings:sclick:110:{
  lqflags
}
on *:dialog:sisettings:dclick:73:{
  var %bchan = $gettok($gettok($did(73).seltext,6,32),1,9)
  if (%bchan != $null) {
    dialog -mav chanedit chanedit
    dialog -t chanedit $trans(EditChan)
    did -a chanedit 4 %bchan
    did -a chanedit 5 $hget(performcnet, %bchan)
    did -a chanedit 6 $hget(performckey, %bchan)
    did -b chanedit 4
    did -e chanedit 7
  }
}
on *:dialog:sisettings:dclick:44:{
  var %bchan = $gettok($gettok($did(44).seltext,6,32),1,9)
  if (%bchan != $null) {
    dialog -mav keyedit keyedit
    dialog -t keyedit $trans(EditKey)
    did -a keyedit 3 %bchan
    did -a keyedit 4 $hget(bfchans, %bchan)
    if ($hget(bfautochans, %bchan)) {
      did -c keyedit 5
    }
    did -b keyedit 3
    did -e keyedit 6
  }
}
on *:dialog:sisettings:sclick:45:{
  if ($did(44).seltext == $null) { return }
  var %bchan = $gettok($gettok($did(44).seltext,6,32),1,9)
  blowfish -r %bchan
  updbfchans $dname
}
on *:dialog:sisettings:sclick:46:{
  dialog -mav keyedit keyedit
  dialog -t keyedit $trans(AddKey)
}
on *:dialog:sisettings:sclick:26:{
  linesep
  xecho Preview: $smp3txt(preview)
}
on *:dialog:sisettings:sclick:24:{
  skined
}
on *:dialog:sisettings:sclick:105:{
  skinview
}
on *:dialog:sisettings:sclick:31:{
  if ($did($did).state == 0) {
    shroudset smp3showstatus off
    did -b $dname 42
  }
  else {
    shroudset smp3showstatus on
    did -e $dname 42
  }
}
on *:dialog:sisettings:sclick:177:{
  if ($did($did).state == 0) {
    shroudset smp3showurl off
  }
  else {
    shroudset smp3showurl on
  }
}
on *:dialog:sisettings:sclick:4:{
  if ($did($did).state == 0) {
    shroudset smp3infotrigact off
  }
  else {
    shroudset smp3infotrigact on
  }
}
on *:dialog:sisettings:sclick:161:{
  if ($did($did).state == 0) {
    shroudset smp3triggeract off
  }
  else {
    shroudset smp3triggeract on
  }
}
on *:dialog:sisettings:sclick:28:{
  if ($did($did).state == 0) {
    shroudset smp3album off
  }
  else {
    shroudset smp3album on
  }
}
on *:dialog:sisettings:sclick:29:{
  if ($did($did).state == 0) {
    shroudset smp3year off
  }
  else {
    shroudset smp3year on
  }
}
on *:dialog:sisettings:sclick:30:{
  if ($did($did).state == 0) {
    shroudset smp3length off
  }
  else {
    shroudset smp3length on
  }
}
on *:dialog:sisettings:sclick:27:{
  if ($did($did).state == 0) {
    shroudset smp3genre off
  }
  else {
    shroudset smp3genre on
  }
}
on *:dialog:sisettings:edit:39:{
  shroudset smp3prefix $did($did).text
}
on *:dialog:sisettings:edit:41:{
  shroudset smp3trigger $did($did).text
}
on *:dialog:sisettings:edit:42:{
  shroudset smp3status $did($did).text
}
on *:dialog:sisettings:sclick:11:{
  if ($did(11).state == 0) {
    shroudset awbcast off
  }
  else {
    shroudset awbcast on
  }
}
on *:dialog:sisettings:edit:10:{
  shroudset awnick $did($did).text
}
on *:dialog:sisettings:edit:13:{
  shroudset awmsg $did($did).text
}
on *:dialog:sisettings:sclick:18:{
  if ($did($did).state == 0) {
    shroudset fsenabled off
  }
  else {
    shroudset fsenabled on
  }
}
on *:dialog:sisettings:edit:21:{
  shroudset fstrigger $did($did).text
}
on *:dialog:sisettings:edit:23:{
  shroudset fsdir $did($did).text
}
on *:dialog:sisettings:edit:48:{
  shroudset birthday $did($did).text
}
on *:dialog:sisettings:sclick:3:{
  if ($did($did).state == 0) {
    shroudset psyconv off
  }
  else {
    shroudset psyconv on
  }
}
on *:dialog:sisettings:sclick:5:{
  if ($did($did).state == 0) {
    shroudset unbanself off
  }
  else {
    shroudset unbanself on
  }
}
on *:dialog:sisettings:sclick:6:{
  if ($did($did).state == 0) {
    shroudset balloon off
  }
  else {
    shroudset balloon on
  }
}
on *:dialog:sisettings:sclick:7:{
  if ($did($did).state == 0) {
    shroudset docheckip off
  }
  else {
    shroudset docheckip on
  }
}
on *:dialog:sisettings:sclick:35:{
  var %author $$?="Author?"
  :tryagain
  var %acolor $$?="Color?"
  if (%acolor !isnum) {
    if ($?!="You must enter a number! Try again?") { goto tryagain }
    return
  }
  smp3color -a $replace(%author,$chr(32),~) %acolor
  updmp3col
}
on *:dialog:sisettings:sclick:36:{
  var %author $$?="Author?"
  var %aval $$?="Custom value?"
  smp3color -c $replace(%author,$chr(32),~) %aval
  updmp3col
}
on *:dialog:sisettings:sclick:37:{
  var %authorl $did(34).seltext
  var %author $left(%authorl,$calc($pos(%authorl,->)-2))
  smp3color -r $replace(%author,$chr(32),~)
  updmp3col
}
on *:dialog:sisettings:edit:55:{
  sisetqdata $did($did).text $+ $chr(124) $+ $did(56).text
  if ($did($did).text == $null || $did(56).text == $null) { did -b $dname 182 }
  else { did -e $dname 182 }
}
on *:dialog:sisettings:edit:56:{
  sisetqdata $did(55).text $+ $chr(124) $+ $did($did).text
  if ($did(55).text == $null || $did($did).text == $null) { did -b $dname 182 }
  else { did -e $dname 182 }
}
on *:dialog:sisettings:edit:168:{
  sisetxdata $did($did).text $+ $chr(124) $+ $did(169).text
}
on *:dialog:sisettings:edit:169:{
  sisetxdata $did(168).text $+ $chr(124) $+ $did($did).text
}
on *:dialog:sisettings:sclick:54:{
  if ($did($did).state == 0) {
    shroudset qaskpw off
    did -n $dname 56
  }
  else {
    shroudset qaskpw on
    did -r $dname 56
    did -m $dname 56
    sisetqdata $did(55).text $+ $chr(124) $+ $did(56).text
  }
}
on *:dialog:sisettings:sclick:57:{
  if ($did($did).state == 0) {
    shroudset qsetx off
  }
  else {
    shroudset qsetx on
  }
}
on *:dialog:sisettings:sclick:182:{
  if ($did($did).state == 0) {
    shroudset qchallenge off
  }
  else {
    shroudset qchallenge on
  }
}
on *:dialog:sisettings:sclick:58:{
  if ($did($did).state == 0) {
    shroudset qsetr off
  }
  else {
    shroudset qsetr on
  }
}
on *:dialog:sisettings:sclick:63:{
  if ($did($did).state == 0) {
    shroudset qask off
  }
  else {
    shroudset qask on
  }
}
on *:dialog:sisettings:sclick:64:{
  set %wantauth 1
  if ($siqgetnick) {
    hidenextwho $me
    who $me n%nat,230
  }
}
on *:dialog:sisettings:sclick:171:{
  set %xwantauth 1
  if ($sixgetnick) {
    hidenextwho $me
    who $me n%nat,230
  }
}
on *:dialog:sisettings:sclick:68:{
  var %hchan $?="Channel?"
  if (%hchan == $null) { return }
  chanhide -a %hchan
  updhchanlist
}
on *:dialog:sisettings:sclick:67:{
  if ($did(66).seltext == $null) { return }
  chanhide -r $did(66).seltext
  updhchanlist
}
on *:dialog:sisettings:sclick:75:{
  dialog -mav chanedit chanedit
  dialog -t chanedit $trans(AddChan)
  did -b chanedit 6
}
on *:dialog:sisettings:sclick:76:{
  if ($did(73).seltext == $null) { return }
  performc -r $gettok($gettok($did(73).seltext, 6, 32), 1, 9)
  updpchanlist $dname
}
on *:dialog:sisettings:edit:138:{
  fkeys -as f2 $did($did).text
}
on *:dialog:sisettings:edit:139:{
  fkeys -as f3 $did($did).text
}
on *:dialog:sisettings:edit:86:{
  fkeys -as f4 $did($did).text
}
on *:dialog:sisettings:edit:91:{
  fkeys -as f5 $did($did).text
}
on *:dialog:sisettings:edit:97:{
  fkeys -as f6 $did($did).text
}
on *:dialog:sisettings:edit:103:{
  fkeys -as f7 $did($did).text
}
on *:dialog:sisettings:edit:109:{
  fkeys -as f8 $did($did).text
}
on *:dialog:sisettings:edit:115:{
  fkeys -as f9 $did($did).text
}
on *:dialog:sisettings:edit:121:{
  fkeys -as f10 $did($did).text
}
on *:dialog:sisettings:edit:127:{
  fkeys -as f11 $did($did).text
}
on *:dialog:sisettings:edit:133:{
  fkeys -as f12 $did($did).text
}
on *:dialog:sisettings:edit:141:{
  fkeys -as cf2 $did($did).text
}
on *:dialog:sisettings:edit:142:{
  fkeys -as cf3 $did($did).text
}
on *:dialog:sisettings:edit:143:{
  fkeys -as cf4 $did($did).text
}
on *:dialog:sisettings:edit:95:{
  fkeys -as cf5 $did($did).text
}
on *:dialog:sisettings:edit:101:{
  fkeys -as cf6 $did($did).text
}
on *:dialog:sisettings:edit:107:{
  fkeys -as cf7 $did($did).text
}
on *:dialog:sisettings:edit:113:{
  fkeys -as cf8 $did($did).text
}
on *:dialog:sisettings:edit:119:{
  fkeys -as cf9 $did($did).text
}
on *:dialog:sisettings:edit:125:{
  fkeys -as cf10 $did($did).text
}
on *:dialog:sisettings:edit:131:{
  fkeys -as cf11 $did($did).text
}
on *:dialog:sisettings:edit:137:{
  fkeys -as cf12 $did($did).text
}
on *:dialog:sisettings:dclick:92:{
  var %sel $did($did).seltext
  var %sell = $did($did).sel
  var %chan = $gettok($gettok(%sel, 6, 32), 1, 9)
  var %flags = $gettok(%sel, 10, 32)
  if ($left(%flags,1) != *) {
    var %flags * $+ %flags
  }
  else {
    var %flags $right(%flags,-1)
  }
  hadd -m lflagtab %chan %flags
  hsave -oi lflagtab lqflags.hash lflags
  did -o $dname $did %sell 0 + 0 0 0 %chan $+ $chr(9) $+ + 0 0 0 %flags
  did -c $dname $did %sell
}
on *:dialog:sisettings:dclick:88:{
  var %sel $did($did).seltext
  var %sell = $did($did).sel
  var %chan = $gettok($gettok(%sel, 6, 32), 1, 9)
  var %flags = $gettok(%sel, 10, 32)
  if ($left(%flags,1) != *) {
    var %flags * $+ %flags
  }
  else {
    var %flags $right(%flags,-1)
  }
  hadd -m qflagtab %chan %flags
  hsave -oi qflagtab lqflags.hash qflags
  did -o $dname $did %sell 0 + 0 0 0 %chan $+ $chr(9) $+ + 0 0 0 %flags
  did -c $dname $did %sell
}
on *:dialog:sisettings:sclick:93:{
  dialog -mv lqhelp lqhelp
}
on *:dialog:sisettings:sclick:134:{
  if ($did($did).state == 0) {
    shroudset autoupdate off
  }
  else {
    shroudset autoupdate on
  }
}
on *:dialog:sisettings:sclick:135:{
  if ($did($did).state == 0) {
    shroudset silast off
  }
  else {
    shroudset silast on
  }
}
alias -l updnetlist {
  var %i = 1
  var %cnt = $hget(nickserv,0).item
  did -r $dname 193
  while (%i <= %cnt) {
    var %net = $gettok($hget(nickserv, %i).item, 2, 47)
    var %n = $gettok($hget(nickserv, %i).item, 1, 47)
    did -a $dname 193 0 + 0 0 0 %net $+ $chr(9) $+ + 0 0 0 %n
    inc %i
  }
}
alias -l updasnetlist {
  var %i = 1
  var %cnt = $hget(authserv,0).item
  did -r $dname 185
  while (%i <= %cnt) {
    var %net = $gettok($hget(authserv, %i).item, 2, 47)
    var %n = $gettok($hget(authserv, %i).item, 1, 47)
    did -a $dname 185 0 + 0 0 0 %net $+ $chr(9) $+ + 0 0 0 %n
    inc %i
  }
}
on *:dialog:sisettings:sclick:190:{
  var %net = $?="Network (e.g. Freechat-Network)"
  if (%net == $null) { return }
  var %nick = $?="Nick?"
  if (%nick == $null) { return }
  var %pass = $?*="NickServ-Password?"
  if (%pass == $null) { return }
  if (!%nkey) { set %nkey $randqkey }
  var %file = $newauthfile
  if ($succeeded($sisetnsauth(%file, %nick $+ $chr(124) $+ %pass))) {
    hadd nickserv %nick $+ / $+ %net %file
    hsave -o nickserv nickserv.hash
    did -a $dname 193 0 + 0 0 0 %net $+ $chr(9) $+ + 0 0 0 %nick
  }
}
on *:dialog:sisettings:sclick:186:{
  var %net = $?="Network (e.g. GameSurge)"
  if (%net == $null) { return }
  var %nick = $?="Nick?"
  if (%nick == $null) { return }
  var %pass = $?*="AuthServ-Password?"
  if (%pass == $null) { return }
  if (!%nkey) { set %nkey $randqkey }
  var %file = $newauthfile
  if ($succeeded($sisetasauth(%file, %nick $+ $chr(124) $+ %pass))) {
    hadd authserv %nick $+ / $+ %net %file
    hsave -o authserv authserv.hash
    did -a $dname 185 0 + 0 0 0 %net $+ $chr(9) $+ + 0 0 0 %nick
  }
}
on *:dialog:sisettings:sclick:189:{
  if ($did(193).sel == $null) { return }
  var %net = $gettok($gettok($did(193).seltext, 6, 32), 1, 9)
  var %n = $gettok($did(193).seltext, 10, 32)
  var %file = $hget(nickserv, %n $+ / $+ %net)
  hdel nickserv %n $+ / $+ %net
  hsave -o nickserv nickserv.hash
  did -d $dname 193 $did(193).sel
  .remove %file
}
on *:dialog:sisettings:sclick:187:{
  if ($did(185).sel == $null) { return }
  var %net = $gettok($gettok($did(185).seltext, 6, 32), 1, 9)
  var %n = $gettok($did(185).seltext, 10, 32)
  var %file = $hget(authserv, %n $+ / $+ %net)
  hdel authserv %n $+ / $+ %net
  hsave -o authserv authserv.hash
  did -d $dname 185 $did(185).sel
  .remove %file
}
on *:dialog:sisettings:sclick:140:{
  if ($did(61).sel == $null) { return }
  awxcp -r $did(61).seltext
  did -d $dname 61 $did(61).sel
}
on *:dialog:sisettings:sclick:62:{
  var %net = $?="Network (e.g. QuakeNet)?"
  if (!%net) { return }
  awxcp -a %net
  updxcplist
}
alias -l tabselect {
  if ($1- == 2) { var %tab = 146 }
  elseif ($1- == 2 2) { var %tab = 1 }
  elseif ($1- == 2 3) { var %tab = 8 }
  elseif ($1- == 2 4) { var %tab = 77 }
  elseif ($1- == 2 5) { var %tab = 111 }
  elseif ($1- == 3) { var %tab = 157 }
  elseif ($1- == 3 2) { var %tab = 148 }
  elseif ($1- == 3 3) { var %tab = 71 }
  elseif ($1- == 3 4) { var %tab = 65 }
  elseif ($1- == 4) { var %tab = 157 }
  elseif ($1- == 4 2) { var %tab = 50 }
  elseif ($1- == 4 3) { var %tab = 166 }
  elseif ($1- == 4 4) { var %tab = 200 }
  elseif ($1- == 4 5) { var %tab = 183 }
  elseif ($1- == 5) { var %tab = 157 }
  elseif ($1- == 5 2) { var %tab = 15 }
  elseif ($1- == 5 3) { var %tab = 16 }
  elseif ($1- == 5 4) { var %tab = 17 }
  elseif ($1- == 5 5) { var %tab = 82 }
  elseif ($1- == 5 6) { var %tab = 208 }
  elseif ($1- == 5 7) { var %tab = 184 }
  if (!%tab) { return }
  var %dname = $iif($dname, $dname, sisettings)
  did -f %dname %tab
  did -f %dname 145
}
on *:dialog:sisettings:sclick:145:{
  tabselect $gettok($did($did,1), 4-, 32)
}
on *:dialog:sisettings:sclick:155:{
  var %net = $did(153).seltext
  if (!%net) { return }
  performn -a %net
  performnetslist $dname
}
on *:dialog:sisettings:sclick:154:{
  var %net = $did(151).seltext
  if (!%net) { return }
  performn -r %net
  performnetslist $dname
}
on *:dialog:sisettings:sclick:152:{
  var %sel = $did(151).sel
  if (!%sel || %sel == 1) { return }
  exchangenets $did(151, $calc(%sel - 1)) $did(151, %sel)
  performnetslist $dname
}
on *:dialog:sisettings:sclick:149:{
  var %sel = $did(151).sel
  if (!%sel || %sel == $did(151).lines) { return }
  exchangenets $did(151, $calc(%sel + 1)) $did(151, %sel)
  performnetslist $dname
}
on *:dialog:sisettings:sclick:160:{
  if ($did($did).state == 0) {
    shroudset autoghost off
  }
  else {
    shroudset autoghost on
  }
}
alias sisetup {
  if (!$dialog(sisettings)) {
    dialog -hmv sisettings sisettings
  }
  if ($1 && $1 != 1) {
    did -c sisettings 145 $1-
    tabselect $1-
  }
}
alias xlangdlg {
  dialog -x $1
  dialog -mv sisettings sisettings
  tabselect 2 5
}
alias sisetlangload {
  var %sel = $did(123).seltext
  if (!%sel) { return }
  var %lang = $int($gettok(%sel, 14, 32))
  if (%lang == $shroudget(language)) { return }
  language %lang
  xasync xlangdlg $dname
}
on *:dialog:sisettings:dclick:123:{
  sisetlangload
}
on *:dialog:sisettings:sclick:122:{
  sisetlangload
}
on *:dialog:sisettings:sclick:162:{
  var %hphrase $?="Phrase?"
  if (%hphrase == $null) { return }
  wordfilter -a %hphrase
  updfilterlist
}
on *:dialog:sisettings:sclick:163:{
  if ($did(129).seltext == $null) { return }
  wordfilter -r $did(129).seltext
  updfilterlist
}
on *:dialog:sisettings:sclick:222:{
  var %d = $sdir($shroudget(fsdir))
  if (%d != $null) {
    did -o $dname 23 1 %d
    shroudset fsdir %d
  }
}
on *:dialog:sisettings:sclick:165:{
  shroudset banmask $gettok($gettok($did(165), 1, 40), 1, 41)
}
on *:dialog:sisettings:sclick:172:{
  if ($did($did).state == 0) {
    shroudset xaskpw off
    did -n $dname 169
  }
  else {
    shroudset xaskpw on
    did -r $dname 169
    did -m $dname 169
    sisetxdata $did(168).text $+ $chr(124) $+ $did(169).text
  }
}
on *:dialog:sisettings:sclick:173:{
  if ($did($did).state == 0) {
    shroudset xsetx off
  }
  else {
    shroudset xsetx on
  }
}
on *:dialog:sisettings:sclick:174:{
  if ($did($did).state == 0) {
    shroudset xask off
  }
  else {
    shroudset xask on
  }
}
on *:dialog:sisettings:sclick:176:{
  if ($did($did).state == 0) {
    shroudset bhideforged off
  }
  else {
    shroudset bhideforged on
  }
}
on *:dialog:sisettings:sclick:181:{
  if ($did($did).state != 0) {
    shroudset disabletb off
    tb.init
  }
  else {
    shroudset disabletb on
    if ($dialog(tb)) { dialog -c tb }
  }
}
on *:dialog:sisettings:sclick:179:{
  pnetedit $did(151).seltext
}
alias -l xdisableoptions {
  did -b $dname 167
  did -m $dname 168
  did -m $dname 169
  did -b $dname 170
  did -b $dname 171
  did -b $dname 172
  did -b $dname 173
  did -b $dname 174
  did -b $dname 175
}
alias -l xcheckdll {
  var %v = $dll(shroud.dll, version, 0)
  return $true
  :error
  reseterror
  return $false
}
dialog -l chanedit {
  title "Edit Channel"
  size -1 -1 118 57
  option dbu
  icon data\sircsmall.ico, 0
  text $trans(Channel) $+ :, 1, 4 5 25 8, right
  text $trans(Network) $+ :, 2, 4 18 25 8, right
  text "Key:", 3, 4 31 25 8, right
  edit "", 4, 32 4 83 10, autohs
  edit "", 5, 32 17 83 10, autohs
  edit "", 6, 32 29 83 10, autohs
  button $trans(OK), 7, 78 42 37 12, disable default ok
  button $trans(Cancel), 8, 38 42 37 12, cancel
}
on *:dialog:chanedit:*:*:{
  if ($devent == sclick && $did == 7) {
    if ($did(4) == $null) {
      xecho invalid input
      return
    }
    performc -a $did(4) $did(5) $did(6)
    updpchanlist sisettings
  }
  if ($devent == edit) {
    if ($did(4) == $null) { did -b $dname 7 }
    else { did -e $dname 7 }
    if ($did(5) == $null) { did -b $dname 6 }
    else { did -e $dname 6 }
  }
}
alias chanedit { dialog -mv chanedit chanedit }
dialog -l keyedit {
  title "Edit Key"
  size -1 -1 119 58
  option dbu
  icon data\sircsmall.ico, 0
  text $trans(Target) $+ :, 1, 4 4 25 8, right
  text $trans(Key) $+ :, 2, 4 17 25 8, right
  edit "", 3, 32 3 85 10, autohs
  edit "", 4, 32 16 85 10, autohs
  check $trans(AutoEncr), 5, 3 29 114 10
  button $trans(Ok), 6, 79 42 37 12, disable default ok
  button $trans(Cancel), 7, 39 42 37 12, cancel
}
on *:dialog:keyedit:*:*:{
  if ($devent == sclick && $did == 6) {
    if ($did(3) == $null || $did(4) == $null) {
      xecho invalid input
      return
    }
    blowfish -a $did(3) $did(4)
    if ($did(5).state) { blowfish -f $did(3) }
    else { blowfish -c $did(3) }
    updbfchans sisettings
  }
  if ($devent == edit) {
    if ($did(3) == $null || $did(4) == $null) { did -b $dname 6 }
    else { did -e $dname 6 }
  }
}
alias keyedit { dialog -mv keyedit keyedit }
dialog -l netedit {
  title "Edit Network"
  size -1 -1 117 45
  option dbu
  icon data\sircsmall.ico, 0
  text $trans(Network) $+ :, 2, 4 6 25 8, right
  text $trans(Nick) $+ :, 3, 4 19 25 8, right
  edit "", 4, 32 4 83 10
  edit "", 5, 32 17 83 10
  button $trans(OK), 7, 78 30 37 12, disable default ok
  button $trans(Cancel), 8, 38 30 37 12, cancel
}
alias netedit { dialog -mv netedit netedit }
on *:dialog:sisettings:sclick:191:{
  var %net = $?="Network (e.g. QuakeNet or UnderNet)"
  if (%net == $null) { return }
  netsplit -a %net
  netsplitlistupd
}
on *:dialog:sisettings:sclick:192:{
  if ($did(188).seltext == $null) { return }
  var %net = $did(188).seltext
  netsplit -r %net
  netsplitlistupd
}
alias setup /sisetup $1-
alias shraway.init {
  xhmake awxcp
  xhload awxcp awxcp.hash
  xhmake awnicks
  :error
  reseterror
}
alias -l xcpnickchangeback {
  if ($hget(awnicks, $cid) != $null && $hfind(awxcp, $network, 0) == 0) {
    nick $hget(awnicks, $cid)
  }
}
alias -l xcpnickchange {
  if ($hfind(awxcp, $network, 0) == 0) {
    nick $1
  }
}
alias aw {
  var %msg $shroudget(awmsg)
  if ($away) {
    echo 4 -a $trans(AlreadyAway)
    return
  }
  if ($1 != $null) { var %msg $1- }
  if ($shroudget(awbcast) == on) { scid -a ame $trans(IsAway, %msg) }
  var %d = 1
  while (%d <= $scon(0)) {
    hadd -m awnicks $scon(%d) $scon(%d).me
    inc %d
  }
  if ($shroudget(awnick) != $null) { scid -a xcpnickchange [ [ $!shroudget(awnick) ] ] }
  scid -a raw -q away : $+ %msg
}
alias back {
  if ($away) {
    if ($shroudget(awbcast) == on) { scid -a ame $trans(IsBack, $duration($awaytime), $awaymsg) }
    else { xecho [info] * $me $trans(IsBack, $duration($awaytime), $awaymsg) }
    scid -a xcpnickchangeback
    xhmake awnicks
  }
  scid -a raw -q away
}
alias awset {
  if ($1 == $null) {
    linesep
    xecho Syntax: /awset <name> <value>
    xecho names: defaultmsg broadcast nick
    linesep
    xecho current values:
    xecho defaultmsg= $+ $shroudget(awmsg)
    xecho broadcast= $+ $shroudget(awbcast)
    xecho nick= $+ $shroudget(awnick)
    return
  }
  if ($1 == defaultmsg && $2 != $null) {
    shroudset awmsg $2-
    xecho defaultmsg set to $2-
    return
  }
  if ($1 == broadcast && $2 != $null) {
    shroudset awbcast $2
    xecho broadcast set to $2
    return
  }
  if ($1 == nick) {
    shroudset awnick $2
    xecho away nick set to $2
    return
  }
  xecho unknown <name>: $1
}
alias awxcp {
  if ($1 == $null) {
    xecho Syntax: /awxcp <option> <value>
    xecho command: a command (see below)
    xecho value: a network
    linesep
    xecho commands:
    xecho -a adds an exception
    xecho -r removes an exception
    linesep
    xecho current networks:
    var %cnt = $hget(awxcp, 0).item
    while (%i <= %cnt) {
      xecho $hget(awxcp,%i).item
      inc %i
    }
    return
  }
  if ($2 == $null) {
    xecho please specify a <value>
    return
  }
  if ($1 == -a) {
    hadd awxcp $2
    xecho added $2
  }
  if ($1 == -r) {
    hdel awxcp $2
    xecho removed $2
  }
  hsave -o awxcp awxcp.hash
}
alias shroud.init {
  xhmake temp
  xhmake qauths
  xhmake qauthex
  xhmake si2stats
  xhload si2stats si2stats.hash
  xhmake shroudsettings
  xhload shroudsettings settings.hash
  if (%banstandard != $null) {
    shroudset banmask %banstandard
    unset %banstandard
  }
  xasync dmudll MircIcon data\sirc2gen.ico
  :error
  reseterror
}
alias si2stats {
  var %s = $hget(si2stats, $$1)
  return $iif(%s == $null, 0, %s)
}
alias statsinc {
  hinc -m si2stats $1-
  .timerstatssave 1 5 hsave -o si2stats si2stats.hash
  if ($timer(statsbk) == $null) { .timerstatsbk 1 20 hsave -o si2stats si2stats.hash }
}
alias k23.egg {
  if ($asctime(dm) == 235) {
    if ($left($read(data\k23.dat,1),1) != $chr(3)) {
      xnull $decompress(data\k23.dat)
    }
    filter -fs data\k23.dat @dummywnd
  }
}
alias hidebans {
  hinc temp hidebans $+ $cid 1
}
alias islame {
  return $regex($1-, /(?:lolo|!!|\?!|!\?|0r| !| \?)/)
}
alias engine.init {
  if ($exists(script\engine.mrc) && $exists(speed.dll) && $script(engine.mrc) == $null) { reload -rs script\engine.mrc }
  :error
  reseterror
}
alias dmp3 {
  var %i = 1
  echo $color(info) -at $+(Download of media file ",$nopath($1-)," finished. Press Shift+F5 to play the file with WinAMP.)
  run $+($dll(wa_link.dll,WA_Link_Raw_Stats,WADIR),winamp.exe /add ",$1-,")
}
alias dplay {
  var %shuffle $dll(WA_Link.dll, WA_Link_Raw_Stats, GETSHUFFLE)
  if (%shuffle == $ $+ SHUFFLE_ON) { dll WA_Link.dll WA_Link_Command SHUFFLE }
  dll WA_Link.dll WA_Link_Command EOFPL
  dll WA_Link.dll WA_Link_Command PLAY
  if (%shuffle == $ $+ SHUFFLE_ON) { dll WA_Link.dll WA_Link_Command SHUFFLE }
}
alias comchan {
  var %cnt $comchan($1,0)
  var %i 1
  if ($1 == $null) {
    linesep
    xecho Syntax: /comchan <nick>
    xecho Purpose: shows, which channels you have in common with <nick>
    return
  }
  if (%cnt == 0) {
    describe $active doesn't have any channels in common with $1
    return
  }
  while (%i <= %cnt) {
    if (%i == %cnt && %cnt != 1) { var %cchans = %cchans and $comchan($1, %i) }
    elseif (%i != 1) { var %cchans = %cchans $+ $chr(44) $comchan($1, %i) }
    else { var %cchans = $comchan($1, %i) }
    inc %i
  }
  describe $active has the following channel $+ $iif(%cnt != 1, s) in common with $1 $+ : %cchans
}
alias mask2ident { return $gettok($gettok($1-,2,$asc(!)),1,$asc(@)) }
alias mask2nick { return $gettok($1-,1,$asc(!)) }
alias checkbans {
  var %n = $ibl($1,0)
  if ($me !ison $1 || $me !isop $1) { return }
  while (%n > 0) {
    if (($ibl($1,%n) iswm $address($me,5) || ($mask2host($ibl($1,%n)) iswm $hget(qauths,$cid) $+ $iif($network == Undernet, .users.undernet.org, .users.quakenet.org) && $mask2ident($ibl($1,%n)) iswm $mask2ident($address($me,-1)) && $mask2nick($ibl($1,%n)) iswm $me)) && $shroudget(unbanself) == on && $me isop $1) {
      pushmode $1 -b $ibl($1, %n)
    }
    dec %n
  }
}
alias mask2host {
  return $mid($1, $calc($pos($1,@) + 1))
}
alias commands {
  var %file = $shortfn($mircdir) $+ data\ $+ $shroudget(language) $+ \commands.html
  if (!$exists(%file)) {
    var %file = $shortfn($mircdir) $+ data\1033\commands.html
  }
  browser $+(file://,%file) @commands
}
alias readme {
  var %file = $shortfn($mircdir) $+ data\ $+ $shroudget(language) $+ \readme.html
  if (!$exists(%file)) {
    var %file = $shortfn($mircdir) $+ data\1033\readme.html
  }
  browser $+(file://,%file) @readme
  window -x @readme
}
alias shroudset {
  if ($1 == $null) {
    var %cnt $hget(shroudsettings,0).item
    var %i = 1
    linesep
    xecho current settings:
    while (%i <= %cnt) {
      xecho $+($hget(shroudsettings,%i).item,=,$hget(shroudsettings,%i).data)
      inc %i
    }
    return
  }
  hadd shroudsettings $1 $2-
  hsave -o shroudsettings settings.hash
}
alias shroudget {
  return $hget(shroudsettings,$1)
}
alias checkauth {
  if (%acmd != $null) {
    xasync checkauth $1-
    return
  }
  hadd -m wcmd $cid $+ $1 $2
  hadd -m wparm $cid $+ $1 $3-
  if ($network == QuakeNet || $network == UnderNet || $network == shroudIRC) {
    hidenextwho $1
    pushwho231 $1
  }
  else {
    hidenextwhois $1
    !whois $1
  }
}
alias -l wqueueworker {
  var %f
  while ($numtok(%f, 44) < 50 && $hget(wqueue231,0).item > 0) {
    var %f = $addtok(%f, $hget(wqueue231, 1).item, 44)
    hdel wqueue231 $hget(wqueue231, 1).item
  }
  who %f n%natuh,231
  if ($hget(wqueue231,0).item > 0) {
    .timerwqueue231 1 0 wqueueworker
  }
}
alias pushwho231 {
  hadd -m wqueue231 $1
  .timerwqueue231 1 0 wqueueworker
}
alias xbankick {
  if ($hget(queue. $1 $+ $cid, 0).item > $calc($modespl / 2)) {
    .timer 1 2 checkauth $2 xdoban $1-
  }
  else {
    checkauth $2 xdoban $1-
  }
}
alias xdoban {
  if (* $+ $iif($network == Undernet, .users.undernet.org, .users.quakenet.org) iswm $2) { var %xmode $true }
  else { var %xmode $false }
  if ($4 != $me && $4 isop $3) {
    pushmode $3 -o $4
  }
  elseif ($4 isvoice $3) {
    pushmode $3 -v $4
  }
  if (%xmode == $false) {
    pushmode $3 +b $mask($2, $shroudget(banmask))
  }
  if ($1 != !noauth) {
    pushmode $3 +b $+(*!*@,$1,$iif($network == Undernet, .users.undernet.org, .users.quakenet.org))
    var %f = $true
  }
  if ($5 != $false) {
    pushkick $3-4 $6-
  }
}
alias hascblock {
  var %modes = $gettok($chan($1).mode, 1, 32)
  if (c isincs %modes || S isincs %modes) { return $true }
  else { return $false }
}
alias join.helper {
  var %clones = $clscanint($1, $2)
  var %last = $addr.lastnick($address($1, 2))
  if (%last == <unknown> && $numtok(%clones, 32) == 0) { return $iif($iif($isalias(join.cust), $join.cust($1-)), ( $+ $ifmatch $+ )) }
  if (%clones == $null && %last == $null) { return $null }
  if (%clones != $null && %last == $null) { return (Clones: %clones $+ $iif($iif($isalias(join.cust), $join.cust($1-)), $chr(44) $ifmatch) $+ ) }
  if (%clones == $null && %last != $null && $shroudget(silast) != off) { return (Last nick: %last $+ $iif($iif($isalias(join.cust), $join.cust($1-)), $chr(44) $ifmatch) $+ ) }
  if (%clones != $null && %last != $null && $shroudget(silast) != off) {
    if (%clones = %last) {
      return (Clone/Last nick: %clones $+ $iif($iif($isalias(join.cust), $join.cust($1-)), $chr(44) $ifmatch) $+ )
    }
    else {
      return (Clone $+ $iif($numtok(%clones, 32) > 1,s) $+ : %clones $+ , Last nick: %last $+ $iif($iif($isalias(join.cust), $join.cust($1-)), $chr(44) $ifmatch) $+ )
    }
  }
}
alias clscanintb { return $join.helper $1-2 }
alias hdump {
  if ($1 == $null) {
    var %cnt = $hget(0)
  }
  else {
    var %cnt = $hget($1,0).item
  }
  var %i = 1
  linesep
  while (%i <= %cnt) {
    if ($1 != $null) {
      var %item = $hget($1, %i).item
      var %data = $hget($1, %i).data
    }
    else {
      var %item = $hget(%i)
    }
    if (!%data) {
      xecho %item
    }
    else {
      xecho %item -> %data
    }
    inc %i
  }
  if (%cnt == 0) { xecho no entries }
}
alias siasyncdownload {
  if ($fopen(patches)) { .fclose patches }
  if ($exists($2)) { .remove $2 }
  xnull $dllcall(shroud.dll,xnull,asyncdownload,$1-)
}
alias siasyncdownloaddirect {
  if ($exists($2)) { .remove $2 }
  xnull $dllcall(shroud.dll,xnull,asyncdownloaddirect,$1-)
}
alias decrypteasteregg {
  var %n 1
  if ($1 == $null) { xecho Specify the crypt key: /decryptfile key | return }
  if ($read(data\crypted.txt, 1) == $null) { xecho Sorry, your version of shroudIRC does not contain this easteregg. | return }
  window -a @easteregg
  while ($true) {
    var %text = $read(data\crypted.txt,%n)
    if (%n > 3639) { return }
    aline @easteregg line %n $+ $bnext($bfdll(Decrypt,$1 %text))
    inc %n
  }
  window -c @easteregg
}
alias ifnet {
  if ($right($server,$len($1)) == $1) {
    . $2-
  }
}
alias mquit { var %t = $read(data\quit.txt) | echo -s %t | return %t }
alias browser {
  if (!$1) { return }
  if (!$window($iif($2, $2, @browser))) {
    window -pak0 $iif($2, $2, @browser)
    htmldll attach $window($iif($2, $2, @browser)).hwnd
    htmldll handler browser_handler
  }
  else {
    var %selected = $htmldll(selected,0)
    window -pak0 $iif($2, $2, @browser)
    htmldll select $window($iif($2, $2, @browser)).hwnd
  }
  htmldll navigate $$1
  if (%selected) {
    htmldll select %selected
  }
}
alias browser_handler {
  if ($2 == title_change) {
    var %i = 1
    var %cnt = $window(0)
    while (%i <= %cnt) {
      if ($window(%i).hwnd == $1) {
        renwin $window(%i) $window(%i) $3-
      }
      inc %i
    }
  }
  if ($2 == navigate_begin) {
    if ($left($3, 9) == shroudirc) {
      var %dest = $gettok($3, 2, $asc(:))
      if (setup* iswm %dest) {
        setup $replace($gettok(%dest, 2, 123), $chr(125),,_,$chr(32))
      }
      if (%dest == qb) { qb }
      if (%dest == kte) { kte_load }
      if (%dest == skinview) { skinview }
      if (%dest == performnets) {
        var %d = 1
        while (%d <= $scon(0)) {
          if ($scon(%d).status != disconnected) {
            xnull $input(You are already connected.,o,Readme)
            return S_CANCEL
          }
          inc %d
        }
        if ($window($gettok($htmldll(caption,$1), 1, 32))) { xasync window -c $gettok($htmldll(caption,$1), 1, 32) }
        xasync doperformn
      }
      if (%dest == commands) { commands }
      if (%dest == close) { xasync window -c $gettok($htmldll(caption,$1), 1, 32) }
      return S_CANCEL
    }
  }
  return S_OK
}
alias language.addtoken {
  hadd language_ $+ $shroudget(language) ID_ $+ $$1 $$2-
  hsave -o language_ $+ $shroudget(language) data\trans\ $+ $shroudget(language) $+ .lang
}
alias language.rehash {
  if ($shroudget(language) != 1033) {
    if ($hget(language_1033)) { hfree language_1033 }
    xhmake language_1033
    hload language_1033 data\trans\1033.lang
    yecho loading language: '1033'
  }
  if ($hget(language_ $+ $shroudget(language))) {
    hfree language_ $+ $shroudget(language)
  }
  language.load $shroudget(language)
}
alias language.load {
  if (!$hget(language_ $+ $1)) {
    yecho $iif($1 == 1033, loading, overlaying) language: ' $+ $1 $+ '
  }
  xhmake language_ $+ $1
  xhload language_ $+ $1 $shortfn($mircdir) $+ data\trans\ $+ $1 $+ .lang
}
alias language {
  if (!$1) {
    linesep
    xecho Syntax:
    xecho /language <id> (loads a language)
    xecho /language -i (spews information about current language)
    xecho <id>: the language identifier (e.g. 1033 (English) or 1031 (German))
    linesep
    xecho current language: $iif($shroudget(language), $ifmatch, none) ( $+ $trans(NativeName) $+ )
    return
  }
  else {
    if ($1 == -i) {
      linesep
      xecho Language-ID: ' $+ $shroudget(language) $+ '
      xecho Maintainer: $hget(language_ $+ $shroudget(language), Maintainer)
      xecho Name: $hget(language_ $+ $shroudget(language), Language)
      xecho Native name: $trans(NativeName)
    }
    else {
      xecho language set to $+(', $1, ')
      shroudset language $1
      language.load $1
    }
  }
}
alias trans {
  var %tr = $hget(language_ $+ $shroudget(language), ID_ $+ $1)
  if (!%tr) {
    var %tr = $hget(language_1033, ID_ $+ $1)
  }
  if (!%tr) {
    var %tr = ID_ $+ $1
  }
  return $replace(%tr, % $+ 1, $2, % $+ 2, $3, % $+ 3, $4, % $+ 4, $5, % $+ 6, $7, % $+ 8, $9, % $+ 9, $10, % $+ 10, $11)
}
alias succeeded {
  if ($gettok($1, 1, 32) == 0) { return $false }
  else { return $true }
}
alias shrouddll {
  return $dll(shroud.dll, $1, $2-)
}
alias mdxdll {
  return $dll(mdx\mdx.dll, $1, $2-)
}
alias htmldll {
  return $dll(nhtmln.dll, $1, $2-)
}
alias wadll {
  return $dll(wa_link.dll, $1, $2-)
}
alias traydll {
  return $dll(SysTray.dll, $1, $2-)
}
alias bfdll {
  return $dll(blowfish.dll, $1, $2-)
}
alias unzipdll {
  return $dll(mUnzip.dll, $1, $2-)
}
alias dmudll {
  return $dll(dmu.dll, $1, $2-)
}
alias dockdll {
  return $dll(mdock61.dll, $1, $2-)
}
alias suid {
  inc %suid
  return $calc(%suid + 200)
}
alias wa_PLAY wadll WA_Link_Command PLAY
alias hideevents {
  hadd -m hideevents n $+ $suid $1-2
}
alias banhit {
  var %d = 1
  while (%d <= $ialchan($1, $2, 0)) {
    var %a = %a $ialchan($1, $2, %d).nick
    inc %d
  }
  return $iif(%a, %a $iif(!$chan($chan).ial, (IAL is not updated)))
}
alias _shroudirc { return shroudIRC $shroudget(VERSION) }
alias select {
  sline -s $chan $ialchan($$1, $chan, 1).nick
  var %d = 2
  while ($ialchan($$1, $chan, %d)) {
    sline -a $chan $ialchan($$1, $chan, %d).nick
    inc %d
  }
}
alias siktereload {
  var %scheme = $hget(Kte_Data, CurScheme)
  kte_load $hget(kte_data, curtheme)
  if (%scheme) { kte_scheme %scheme }
}
alias shroudamp.init {
  xhmake smp3colors
  xhload smp3colors shroudamp.hash
  xhmake smp3skin
  if ($exists($shroudget(smp3skinfile))) {
    yecho loaded: $shroudget(smp3skinfile)
    hload smp3skin $shroudget(smp3skinfile)
  }
  else {
    hload smp3skin $+(data\skins\,$shroudget(smp3skinfile))
  }
  loadscriptfromhash
  xhmake smp3info
  xhload smp3info smp3info.hash
  :error
  reseterror
}
alias smp3raw { return $wadll(WA_Link_Raw_Stats, $$1) }
alias smp3txt {
  if ($1 != preview) {
    var %titleraw $smp3raw(TITLE)
    if (%titleraw == $false) { xecho WinAMP isn't running or WA_LINK could not retrieve the necessary data. | return $null }
    var %possec $smp3raw(POSSEC)
    var %tracksec $smp3raw(TRACKSEC)
    var %author $smp3raw(ARTIST)
    var %authorc $smp3colorize(%author)
    var %title $replace(%titleraw,.avi, [Video],.mpg, [Video],.ogg, [Ogg Vorbis])
    if ($isalias(smp3filter)) {
      var %title = $smp3filter(%title)
    }
    var %genre $smp3raw(GENRE)
    var %album $smp3raw(ALBUM)
    var %length $duration(%tracksec)
    var %year $smp3raw(YEAR)
    var %file $smp3raw(TRACKFILENAME)
    if ($left(%file, 5) == http:) {
      var %url = %file
      var %file
    }
    else {
      var %url
    }
    var %vc = [ [ $shroudget(smp3status) ] ]
    if (%vc == $false) { var %vc }
    var %lc $int($calc(%possec / %tracksec * $len(%vc)))
    var %status = $+(,$smp3skinv(barx),$left(%vc, %lc),,$smp3skinv(bary),$mid(%vc, $calc(%lc + 1), $calc($len(%vc) - %lc + 1)))
    var %statuspc $int($calc(%possec / %tracksec * 100))
    if ($shroudget(smp3showstatus) == on && $len(%vc) == 0) {
      var %status %statuspc $+ %
    }
    var %trigger [ [ $shroudget(smp3trigger) ] ]
  }
  else {
    var %possec 104
    var %tracksec 244
    var %author Battlelore
    var %authorc $smp3colorize(%author)
    var %title Shadowgate
    if ($isalias(smp3filter)) {
      var %title = $smp3filter(%title)
    }
    var %genre Metal
    var %album ...Where The Shadows Lie
    var %length 4mins 4secs
    var %year 2002
    var %vc = [ [ $shroudget(smp3status) ] ]
    if (%vc == $false) { var %vc }
    var %lc $int($calc(0.43 * $len(%vc)))
    var %status = $+(,$smp3skinv(barx),$left(%vc, %lc),,$smp3skinv(bary),$mid(%vc, $calc(%lc + 1), $calc($len(%vc) - 0.43 * $len(%vc) + 1)))
    var %statuspc 43
    if ($shroudget(smp3showstatus) == on && $len(%vc) == 0) {
      var %status %statuspc $+ %
    }
    var %trigger !shroudirc
    var %file D:\Programme\mIRC\download\mp3\Battlelore - ...Where The Shadows Lie - 05 - Shadowgate.mp3
  }
  var %sprefix $shroudget(smp3prefix)
  var %sauthor [ [ $smp3skinv(author) ] ]
  var %stitle [ [ $smp3skinv(title) ] ]
  if ($shroudget(smp3genre) == on && %genre != $false) { var %sgenre [ [ $smp3skinv(genre) ] ] }
  if ($shroudget(smp3length) == on) { var %slength [ [ $smp3skinv(length) ] ] }
  if ($shroudget(smp3album) == on && %album != $false) { var %salbum [ [ $smp3skinv(album) ] ] }
  if ($shroudget(smp3year) == on && %year != $false) { var %syear [ [ $smp3skinv(year) ] ] }
  if ($shroudget(smp3showurl) == on && %url != $null) { var %surl [ [ $smp3skinv(url) ] ] }
  if ($shroudget(smp3triggeract) == on && $shroudget(smp3trigger) != $null) { var %strigger [ [ $smp3skinv(trigger) ] ] }
  if ($shroudget(smp3showstatus) == on) { var %sstatus [ [ $smp3skinv(status) ] ] }
  if ($1 != preview) {
    if (%tracksec == $false || $shroudget(smp3showstatus) != on || $hascblock($1)) { var %sstatus }
    if (http* iswm $smp3raw(TRACKFILENAME) && %author != $false) {
      var %sstatus
      var %slength
    }
  }
  var %mp3skin [ [ [ $smp3skinv(mp3) ] ] ]
  return %mp3skin
}
alias smp3 {
  var %mp3chan $1
  if ($1 == $null) { var %mp3chan $active }
  if (($shroudget(smp3info) == wl && $hget(smp3info, %mp3chan) == $null) || ($shroudget(smp3info) != wl && $hget(smp3info, %mp3chan) != $null)) {
    echo -a You have disabled the mp3-script for this channel, you can change these settings using /smp3info
    return
  }
  var %txt $smp3txt(%mp3chan)
  if (%txt != $null) {
    if ($smp3skinv(describe) != 1) {
      xmsg %mp3chan $stripc(%txt)
    }
    else {
      describe %mp3chan $stripc(%txt)
    }
  }
}
alias smp3set {
  if ($1 == $null) {
    linesep
    xecho syntax: /smp3set <name> <value>
    xecho names: triggeract trigger genre length album year status lockmsg prefix
    xecho values: on off and anything for "trigger" and "status"
    linesep
    xecho current settings:
    xecho triggeract= $+ $shroudget(smp3triggeract)
    xecho trigger= $+ $shroudget(smp3trigger)
    xecho genre= $+ $shroudget(smp3genre)
    xecho length= $+ $shroudget(smp3length)
    xecho album= $+ $shroudget(smp3album)
    xecho year= $+ $shroudget(smp3year)
    xecho status= $+ $shroudget(smp3status)
    xecho url= $+ $shroudget(smp3showurl)
    xecho lockmsg= $+ $shroudget(smp3lockmsg)
    xecho prefix= $+ $shroudget(smp3prefix)
    xecho showstatus= $+ $shroudget(smp3showstatus)
  }
  if ($1 == triggeract) {
    shroudset smp3triggeract $$2
  }
  if ($1 == trigger) {
    shroudset smp3trigger $2
  }
  if ($1 == genre) {
    shroudset smp3genre $$2
  }
  if ($1 == length) {
    shroudset smp3length $$2
  }
  if ($1 == album) {
    shroudset smp3album $$2
  }
  if ($1 == year) {
    shroudset smp3year $$2
  }
  if ($1 == status) {
    shroudset smp3status $2
  }
  if ($1 == lockmsg) {
    shroudset smp3lockmsg $$2-
  }
  if ($1 == prefix) {
    shroudset smp3prefix $$2
  }
  if ($1 == showstatus) {
    shroudset smp3showstatus $$2
  }
  if ($1 == url) {
    shroudset smp3showurl $$2
  }
  if ($1 != $null || $1 == status || $1 == trigger) {
    if ($2 == $null) {
      xecho $1 unset
      return
    }
    xecho $1 set to $2-
  }
}
alias smp3colorize {
  var %cust $hget(smp3colors,$replace($$1,$chr(32),~))
  if (%cust == $null) { return $1 }
  return %cust
}
alias smp3color {
  if ($1 == $null) {
    var %cnt $hget(smp3colors,0).item
    var %i = 1
    var %jback 1
    goto syntax
    :jback
    linesep
    xecho current values:
    while (%i <= %cnt) {
      echo -a $hget(smp3colors,%i).data
      inc %i
    }
    return
  }
  if ($1 == -l) {
    xhload smp3colors shroudamp.hash
    xecho colors reloaded
    return
  }
  var %p2 $replace($$2,~,$chr(32))
  if ($1 == -r && $2 != $null) {
    hdel smp3colors $$2
    hsave -o smp3colors shroudamp.hash
    xecho %p2 removed
    return
  }
  if ($1 == -a && $2 != $null && $3- != $null) {
    var %entry = $+(,$$3-,%p2)
    hadd -m smp3colors $$2 %entry
    hsave -o smp3colors shroudamp.hash
    echo -a %p2 -> %entry
    return
  }
  if ($1 == -c && $2 != $null && $3 != $null) {
    hadd -m smp3colors $$2 $$3-
    hsave -o smp3colors shroudamp.hash
    echo -a %p2 -> $$3-
    return
  }
  :syntax
  linesep
  xecho Syntax:
  xecho   add: /smp3color -a <name> <value>
  xecho   add (custom format): /smp3color -c <name> <value>
  xecho   remove: /smp3color -r <name>
  xecho   view: /smp3color
  xecho   reload from disk: /smp3color -l
  if (%jback) { goto jback }
}
alias smp3lock {
  smp3set triggeract off
}
alias smp3unlock {
  smp3set triggeract on
}
alias smp3loadfinal {
  smp3skinv describe 0
  xhmake smp3skin
  hload smp3skin data\skins\ $+ $$1-
  loadscriptfromhash
  shroudset smp3skinfile $$1-
}
alias smp3skin {
  if ($1 == $null) {
    linesep
    xecho set value: /smp3skin <name> <value>
    xecho reload default skin: /smp3skin -r
    xecho load skin: /smp3skin -l <file>
    xecho save skin: /smp3skin -s <file>
    linesep
    xecho names: mp3 author title length genre album year bar trigger
    xecho values: custom skin
    xecho variables % $+ author % $+ authorc % $+ title % $+ length % $+ album % $+ year % $+ status % $+ statuspc % $+ trigger
    xecho variables for mp3: % $+ sauthor % $+ stitle % $+ slength % $+ sgenre % $+ salbum % $+ syear % $+ sstatus %  $+ strigger
    linesep
    xecho current settings:
    xecho mp3= $+ $smp3skinv(mp3)
    xecho author= $+ $smp3skinv(author)
    xecho title= $+ $smp3skinv(title)
    xecho length= $+ $smp3skinv(length)
    xecho genre= $+ $smp3skinv(genre)
    xecho album= $+ $smp3skinv(album)
    xecho year= $+ $smp3skinv(year)
    xecho status= $+ $smp3skinv(status)
    xecho trigger= $+ $smp3skinv(trigger)
    xecho url= $+ $smp3skinv(url)
    xecho barcolor1= $+ $smp3skinv(barx)
    xecho barcolor2= $+ $smp3skinv(bary)
    xecho describe= $+ $smp3skinv(discribe)
  }
  if ($1 == -r) {
    smp3skinv mp3 0,1 $ $+ + % $+ sprefix $ $+ + AMP: % $+ sauthor $ $+ + 0,1 - % $+ stitle % $+ sgenre % $+ salbum % $+ syear % $+ slength % $+ sstatus % $+ strigger
    smp3skinv author  $ $+ + % $+ authorc $ $+ + 
    smp3skinv title % $+ title
    smp3skinv length [Länge: % $+ length $ $+ + ]
    smp3skinv genre [Genre: % $+ genre $ $+ + ]
    smp3skinv album [Album: % $+ album $ $+ + ]
    smp3skinv year [Jahr: % $+ year $ $+ + ]
    smp3skinv status [ $ $+ + % $+ status $ $+ + 0,1]
    smp3skinv trigger [Trigger: % $+ trigger  $ $+ + ]
    smp3skinv url [Url: % $+ url  $ $+ + ]
    smp3skinv barx 4
    smp3skinv bary 14
    smp3skinv describe 0
    xecho default skin reloaded
    return
  }
  if ($1 == -l) {
    if ($scantheme(data\skins\ $+ $$2)) { scriptwarn data\skins\ $+ $$2 | return }
    smp3loadfinal $$2-
    return
  }
  if ($1 == -s) {
    hsave -o smp3skin data\skins\ $+ $$2-
    xecho skin saved to $$2
    shroudset smp3skinfile $$2
    return
  }
  if ($1 == mp3) {
    smp3skinv mp3 $2-
  }
  if ($1 == author) {
    smp3skinv author $2-
  }
  if ($1 == title) {
    smp3skinv title $2-
  }
  if ($1 == length) {
    smp3skinv length $2-
  }
  if ($1 == genre) {
    smp3skinv genre $2-
  }
  if ($1 == album) {
    smp3skinv album $2-
  }
  if ($1 == year) {
    smp3skinv year $2-
  }
  if ($1 == trigger) {
    smp3skinv trigger $2-
  }
  if ($1 == status) {
    smp3skinv status $2-
  }
  if ($1 == barcolor1) {
    smp3skinv barx $2
  }
  if ($1 == barcolor2) {
    smp3skinv bary $2
  }
  if ($1 == describe) {
    smp3skinv describe $2
  }
  if ($1 == url) {
    smp3skinv url $2
  }
  xecho $1 set to $$2-
}
alias smp3skinv {
  if ($2 == $null) {
    if ($1 == mp3) { return $hget(smp3skin,mp3) }
    if ($1 == author) { return $hget(smp3skin,author) }
    if ($1 == title) { return $hget(smp3skin,title) }
    if ($1 == length) { return $hget(smp3skin,length) }
    if ($1 == genre) { return $hget(smp3skin,genre) }
    if ($1 == album) { return $hget(smp3skin,album) }
    if ($1 == year) { return $hget(smp3skin,year) }
    if ($1 == status) { return $hget(smp3skin,status) }
    if ($1 == trigger) { return $hget(smp3skin,trigger) }
    if ($1 == url) { return $hget(smp3skin,url) }
    if ($1 == barx) { return $hget(smp3skin,barx) }
    if ($1 == bary) { return $hget(smp3skin,bary) }
    if ($1 == describe) { return $hget(smp3skin,describe) }
  }
  if ($1 == mp3) { hadd -m smp3skin mp3 $iif($2- == remove, $null, $2-) }
  if ($1 == author) { hadd -m smp3skin author $iif($2- == remove, $null, $2-) }
  if ($1 == title) { hadd -m smp3skin title $iif($2- == remove, $null, $2-) }
  if ($1 == length) { hadd -m smp3skin length $iif($2- == remove, $null, $2-) }
  if ($1 == album) { hadd -m smp3skin album $iif($2- == remove, $null, $2-) }
  if ($1 == genre) { hadd -m smp3skin genre $iif($2- == remove, $null, $2-) }
  if ($1 == year) { hadd -m smp3skin year $iif($2- == remove, $null, $2-) }
  if ($1 == status) { hadd -m smp3skin status $iif($2- == remove, $null, $2-) }
  if ($1 == trigger) { hadd -m smp3skin trigger $iif($2- == remove, $null, $2-) }
  if ($1 == url) { hadd -m smp3skin url $iif($2- == remove, $null, $2-) }
  if ($1 == barx) { hadd -m smp3skin barx $iif($2- == remove, $null, $2-) }
  if ($1 == bary) { hadd -m smp3skin bary $iif($2- == remove, $null, $2-) }
  if ($1 == describe) { hadd -m smp3skin describe $iif($2- == remove, $null, $2-) }
  hsave -o smp3skin data\skins\ $+ edited.skin
  shroudset smp3skinfile edited.skin
}
alias savescripttohash {
  var %cnt = $did($1, $2, 1).lines
  var %c = 1
  var %v = 1
  hdel -w smp3skin scriptn*
  while (%c <= %cnt) {
    if ($did($1, $2, %v).text != $null) {
      hadd -m smp3skin scriptn $+ %c $did($1, $2, 1, %v).text
      inc %c
    }
    else {
      dec %cnt
    }
    inc %v
  }
  hsave -o smp3skin data\skins\ $+ edited.skin
  shroudset smp3skinfile edited.skin
  loadscriptfromhash
}
alias loadscripttodlg {
  var %c = 1
  while ($hget(smp3skin, scriptn $+ %c) != $null) {
    did -a $1 $2 $hget(smp3skin, scriptn $+ %c) $+ $crlf
    inc %c
  }
}
alias loadscriptfromhash {
  .unload -rs mp3res.mrc
  if ($fopen(mp3scriptf) != $null) { .fclose mp3scriptf }
  .fopen -o mp3scriptf data\mp3res.mrc
  var %c = 1
  while ($hget(smp3skin, scriptn $+ %c) != $null) {
    .fwrite -n mp3scriptf $hget(smp3skin, scriptn $+ %c)
    inc %c
  }
  .fclose mp3scriptf
  .load -rs data\mp3res.mrc
}
dialog -l scriptwarn {
  title shroudAMP: $trans(SecWarn)
  size -1 -1 202 100
  option dbu
  button $trans(Cancel), 5, 160 83 37 12, default
  button $trans(Continue), 4, 120 83 37 12
  text $trans(FileC), 1, 5 5 25 8, right
  edit "", 2, 34 4 164 10, read
  text $trans(SecWarnTxt), 3, 5 18 192 61
}
on *:dialog:scriptwarn:*:*:{
  if ($devent == sclick) {
    if ($did == 4) {
      smp3loadfinal $nopath($did(2).text)
      dialog -c $dname
      if ($dialog(skined)) {
        dialog -x skined
        skined
      }
      if ($dialog(skinview)) {
        dialog -x skinview
        skinview
      }
    }
    if ($did == 5) { dialog -c $dname }
  }
}
alias -l scriptwarn { dialog -omv scriptwarn scriptwarn | did -a scriptwarn 2 $$1- }
alias -l scantheme {
  xhmake temptheme
  hload temptheme $1-
  var %scr = $hget(temptheme, scriptn1)
  hfree temptheme
  if (%scr == $null) { return $false }
  else { return $true }
}
alias smp3info {
  if ($1 == $null) {
    linesep
    xecho add channel: /smp3info -a <channel>
    xecho remove channel: /smp3info -r <channel>
    xecho switch to blacklist behavior: /smp3info -b
    xecho switch to whitelist behavior: /smp3info -w
    xecho view: /smp3info
    linesep
    xecho current behavior: $iif($shroudget(smp3info) == wl, whitelist, blacklist)
    linesep
    xecho current channels:
    var %i = 1
    while (%i <= $hget(smp3info, 0).data) {
      xecho $hget(smp3info, %i).item
      inc %i
    }
  }
  if ($1 == -w) {
    xecho behavior set to 'whitelist'
    shroudset smp3info wl
  }
  if ($1 == -b) {
    xecho behavior set to 'blacklist'
    shroudset smp3info bl
  }
  if ($1 == -a && $2 != $null) {
    if ($hget(smp3info, $2) != $null) { xecho $2 already exists in the list | return }
    hadd -m smp3info $2 1
    hsave -o smp3info smp3info.hash
    xecho added $2
  }
  if ($1 == -r && $2 != $null) {
    if ($hget(smp3info, $2) == $null) { xecho $2 could not be found | return }
    hdel smp3info $2
    hsave -o smp3info smp3info.hash
    xecho removed $2
  }
}
alias mp3 /smp3 $1-
dialog -l modelock {
  title "shroudIRC: Modelock"
  size -1 -1 185 140
  option dbu
  icon data\sircsmall.ico, 0
  check "+i (invite only)", 1, 9 41 70 10
  check "+k (channel key)", 2, 9 54 70 10
  check "+l (limit)", 3, 9 67 70 10
  check "+r (registered only)", 4, 83 41 90 10
  check "+m (moderated)", 6, 83 54 90 10
  button $trans(Ok), 5, 143 124 37 12, default ok
  text $trans(ModelockHelp), 7, 4 4 176 25
  text "", 8, 110 126 27 8, hide
  box $trans(DisallowedChanModes), 10, 4 33 177 48
  box $trans(MLReactionGlobal), 11, 4 83 177 38
  radio $trans(MLNone), 12, 9 92 72 10
  radio $trans(MLKickBan), 13, 9 105 92 10
  radio $trans(BlacklistOffenders), 9, 83 92 84 10
  check "+b (bans, which affect me)", 14, 83 67 90 10
}
alias modelock { if (!$dialog(modelock)) { dialog -mv modelock modelock } }
on *:dialog:modelock:*:*:{
  if ($devent == init) {
    if ($active !ischan) { dialog -c $dname | xecho $active is not a channel. | return }
    if (!$atmodeallowed($network $+ / $+ $active,i)) { did -c $dname 1 }
    if (!$atmodeallowed($network $+ / $+ $active,k)) { did -c $dname 2 }
    if (!$atmodeallowed($network $+ / $+ $active,l)) { did -c $dname 3 }
    if (!$atmodeallowed($network $+ / $+ $active,r)) { did -c $dname 4 }
    if (!$atmodeallowed($network $+ / $+ $active,m)) { did -c $dname 6 }
    if (!$atmodeallowed($network $+ / $+ $active,p)) { did -c $dname 9 }
    if ($atmodeallowed($network $+ / $+ $active,p) && $atmodeallowed($network $+ / $+ $active,b)) { did -c $dname 12 }
    if (!$atmodeallowed($network $+ / $+ $active,b)) { did -c $dname 13 }
    if (!$atmodeallowed($network $+ / $+ $active,f)) { did -c $dname 14 }
    dialog -t $dname shroudIRC: Modelock ( $+ $network $+ / $+ $active $+ )
    did -a $dname 8 $network $+ / $+ $active
  }
  elseif ($devent == sclick) {
    var %mlock 0
    if ($did($dname, 1).state != 0) { var %mlock $eval(%mlock, 2) $+ i }
    if ($did($dname, 2).state != 0) { var %mlock $eval(%mlock, 2) $+ k }
    if ($did($dname, 3).state != 0) { var %mlock $eval(%mlock, 2) $+ l }
    if ($did($dname, 4).state != 0) { var %mlock $eval(%mlock, 2) $+ r }
    if ($did($dname, 6).state != 0) { var %mlock $eval(%mlock, 2) $+ m }
    if ($did($dname, 9).state != 0) { var %mlock $eval(%mlock, 2) $+ p }
    if ($did($dname, 13).state != 0) { var %mlock $eval(%mlock, 2) $+ b }
    if ($did($dname, 14).state != 0) { var %mlock $eval(%mlock, 2) $+ f }
    atakeset $did($dname, 8).text %mlock
  }
}
dialog -l skined {
  icon data\sircsmall.ico
  title shroudAMP: $trans(SkinEditor)
  size -1 -1 414 181
  option dbu
  text "mp3:", 1, 5 5 14 8
  text "author:", 2, 5 17 21 8
  text "title:", 3, 5 29 13 8
  text "length:", 4, 5 41 20 8
  text "genre:", 5, 5 53 19 8
  text "album:", 6, 5 65 18 8
  text "year:", 7, 5 77 16 8
  text "status:", 8, 5 89 19 8
  text "trigger:", 9, 5 101 21 8
  edit $smp3skinv(mp3), 20, 29 4 380 10, autohs
  edit $smp3skinv(author), 19, 29 16 380 10, autohs
  edit $smp3skinv(title), 18, 29 28 380 10, autohs
  edit $smp3skinv(length), 17, 29 41 380 10, autohs
  edit $smp3skinv(genre), 16, 29 52 380 10, autohs
  edit $smp3skinv(album), 15, 29 64 380 10, autohs
  edit $smp3skinv(year), 13, 29 76 380 10, autohs
  edit $smp3skinv(status), 14, 29 88 380 10, autohs
  edit $smp3skinv(trigger), 12, 29 100 380 10, autohs
  edit $smp3skinv(url), 33, 29 112 380 10, autohs
  edit $smp3skinv(barx), 10, 29 124 30 10, autohs
  edit $smp3skinv(bary), 11, 29 136 30 10, autohs
  text "bar1:", 31, 5 125 17 8
  text "bar2:", 30, 5 137 17 8
  check "use /describe", 29, 65 124 50 10
  button "?", 21, 113 133 15 12
  button "SkinViewer", 28, 131 133 37 12
  button "ScriptEditor", 35, 171 133 37 12
  button "Load", 26, 211 133 37 12
  button "Save", 22, 251 133 37 12
  button "Preview", 25, 291 133 37 12
  button "Reset", 24, 331 133 37 12
  button "OK", 23, 371 133 37 12, default ok
  box "Quick preview", 34, 4 148 406 29
  icon 27, 7 156 399 15,  script\pics\skined27.bmp, 0, noborder
  text "url:", 32, 5 113 21 8
}
dialog -l skininfo {
  icon data\sircsmall.ico
  title "shroudAMP: skin editor (info)"
  size -1 -1 191 113
  option dbu
  text "The skin editor is an advanced tool, which allows you to customize your mp3-skin. Therefore it should only be used by experienced users.", 1, 5 5 181 15
  text "Valid variables for 'mp3' are: %sauthor %stitle %slength %sgenre %salbum %syear %sstatus %strigger %surl", 2, 5 25 182 18
  text "Valid variables for all the other fields are: %author %title %length %year %status %statuspc %trigger, %file, %url, %authorc (colored author), %barx (bar 1) and %bary (bar 2).", 3, 5 48 182 23
  text "You can also use any other available mIRC variables/aliases, for example: $asctime (current time)", 4, 5 75 183 17
  button "OK", 5, 150 96 37 12, default ok cancel
}
alias edupdmp3prev {
  prevbmp $dname 27 800 $smp3txt(preview)
  if ($smp3skinv(describe)) { did -c $dname 29 }
}
on *:dialog:skined:*:*:{
  if ($devent == init) {
    edupdmp3prev
  }
  elseif ($devent == edit) {
    if ($did == 10) { var %item = barx }
    if ($did == 11) { var %item = bary }
    if ($did == 12) { var %item = trigger }
    if ($did == 13) { var %item = year }
    if ($did == 14) { var %item = status }
    if ($did == 15) { var %item = album }
    if ($did == 16) { var %item = genre }
    if ($did == 17) { var %item = length }
    if ($did == 18) { var %item = title }
    if ($did == 19) { var %item = author }
    if ($did == 20) { var %item = mp3 }
    if ($did == 33) { var %item = url }
    if (%item != $null) {
      smp3skinv %item $iif($did($did).text == $null, remove, $did($did).text)
      prevbmp $dname 27 800 $smp3txt(preview)
      if ($smp3skinv(describe)) { did -c $dname 29 }
    }
  }
  elseif ($devent == sclick) {
    if ($did == 24) {
      if ($?!="Do you want to reset all values?") {
        smp3skin -r
        dialog -x $dname
        dialog -mv skined skined
      }
    }
    elseif ($did == 25) {
      linesep
      xecho Preview: $smp3txt(preview)
    }
    elseif ($did == 21) {
      dialog -ma skininfo skininfo
    }
    else if ($did == 22) {
      var %file $sfile($$mircdir $+ data\skins\,Save skin,Save)
      if (%file == $null) { return }
      hsave -o smp3skin %file
      shroudset smp3skinfile %file
    }
    elseif ($did == 26) {
      var %file $sfile($$mircdir $+ data\skins\)
      if (%file == $null) { return }
      if (!$isfile($mircdir $+ data\skins\ $+ $nopath(%file))) {
        xecho error: skins must be in this folder: $mircdir $+ data\skins
        return
      }
      smp3skin -l $nopath(%file)
      dialog -x $dname
      dialog -mv skined skined
    }
    elseif ($did == 29) {
      smp3skinv describe $did($did).state
    }
    elseif ($did == 28) {
      dialog -x $dname
      skinview
    }
    elseif ($did == 35) {
      scripted
    }
  }
}
alias prevbmp {
  var %win = $+(@,$1,$2)
  window -ph +d %win 0 0 $3 19
  drawfill %win $color(back) $color(back) 0 0
  drawtext -pb %win $color(text) $color(back) $+(",$window(Status Window).font,") $window(Status Window).fontsize 2 1 $iif($4-,$4-,)
  drawsave %win $+(script\pics\,$mid(%win,2),.bmp)
  close -@ %win
  did -g $1-2 $+(script\pics\,$mid(%win,2),.bmp)
}
alias skined { dialog -mv skined skined }
dialog -l scripted {
  icon data\sircsmall.ico
  title "shroudAMP: script editor"
  size -1 -1 308 208
  option dbu
  edit "", 1, 0 0 308 192, multi return autohs autovs hsbar vsbar
  button "Save", 2, 269 193 37 12, disable
}
on *:dialog:scripted:*:*:{
  if ($devent == init) { loadscripttodlg $dname 1 }
  if ($devent == edit && $did == 1) { did -e $dname 2 }
  if ($devent == sclick && $did == 2) { did -b $dname 2 | savescripttohash $dname 1 }
}
alias scripted { dialog -mv scripted scripted }
dialog -l skinview {
  title shroudAMP: $trans(SkinViewer)
  size -1 -1 258 163
  option dbu
  box "Themes", 1, 4 4 250 104
  box $trans(QuickPreview), 2, 4 111 250 31
  button $trans(Ok), 4, 216 147 37 12, default ok cancel
  list 3, 8 12 242 91, size
  icon 5, 8 120 240 15,  script\pics\skinview5.bmp, 0, noborder
}
alias -l vwupdmp3prev {
  prevbmp $dname 5 480 $smp3txt(preview)
}
alias -l addskin {
  did -a $dname 3 $nopath($1-)
  if ($nopath($1-) == $shroudget(smp3skinfile)) {
    did -c $dname 3 $did(3).lines
  }
}
on *:dialog:skinview:*:*:{
  if ($devent == init) {
    vwupdmp3prev
    xnull $findfile($mircdir $+ data\skins,*.skin,0,addskin $1-)
  }
  elseif ($devent == sclick && $did == 3) {
    smp3skin -l $did($did).seltext
    vwupdmp3prev
  }
}
alias skinview { dialog -mv skinview skinview }
alias statsstrip {
  if ($shroudget(statsnocolors) == on) { return $strip($1-,c) }
  return $stripc($1-)
}
alias statsstripx {
  if ($shroudget(statsnocolors) == on) { return $strip($2-,c) }
  return $stripcx($1, $2-)
}
alias statshascblock {
  if ($shroudget(statsnocolors) == on) { return $true }
  return $hascblock($1-)
}
alias nistat {
  var %msg = 4,1net0[ $+ $dll(moo.dll,interfaceinfo,_) $+ ]
  xmsg $active $statsstrip(%msg)
}
alias stat {
  rambar
  var %msg = 4,1os0[ $+ $dll(moo.dll,osinfo,_) $+ ] 4uptime0[ $+ $uptime(system,1) $+ ] 4cpu0[ $+ $dll(moo.dll,cpuinfo,_) $+ ] 4mem0[ $+ $dll(moo.dll,meminfo,_) $+ $result $+ 0,1]
  xmsg $active $statsstrip(%msg)
}
alias diskstat {
  var %msg = 4,1disks0[ $+ $dll(moo.dll,diskcapacity,_) $+ ]
  xmsg $active $statsstrip(%msg)
}
alias screenstat {
  var %msg = 4,1gfx0[ $+ $dll(moo.dll,gfxinfo,_) $+ ] 4screen0[ $+ $dll(moo.dll,screeninfo,_) $+ ]
  xmsg $active $statsstrip(%msg)
}
alias -l rambar {
  var %rb_used = $round($calc($dll(moo.dll,rambar,_) / 100 * 10),0)
  var %rb_unused = $round($calc(10 - %rb_used),0)
  var %rb_usedstr = 4,1 $+ $left($shroudget(vstring),%rb_used)
  var %rb_unusedstr = 14,1 $+ $mid($shroudget(vstring),$calc(%rb_used + 1),%rb_unused)
  if ($statshascblock($active)) {
    return
  }
  else {
    return  14,1[ $+ %rb_usedstr $+ %rb_unusedstr $+ ]
  }
}
alias stripc {
  return $stripcx($active, $1-)
}
alias stripcx {
  if ($hascblock($1)) {
    return $strip($2-,c)
  }
  else {
    return $2-
  }
}
alias sistat {
  var %msg = 4,1shroudIRC0[version $shroudget $shroudget(version) $+ ; release $shroudget(release) $+ ] 4mIRC0[version $version $+ ; online timer: $duration($online) $+ ]
  xmsg $active $statsstrip(%msg)
}
dialog -l si2stats {
  title "shroudIRC Statistics"
  size -1 -1 195 118
  option dbu
  icon data\sircsmall.ico, 0
  list 1, 2 3 190 96, size
  button $trans(Ok), 2, 155 102 37 12, default ok
  button $trans(ResetAll), 3, 3 102 37 12
}
alias si2statsdlg { if (!$dialog(si2stats)) { dialog -mv si2stats si2stats } }
alias updstatsdlg {
  did -r $1 1
  did -a $1 1 Read messages (channel) $+ $chr(9) $+ $chr(160) $+ $si2stats(msgchan)
  did -a $1 1 Read messages (channel, lame) $+ $chr(9) $+ $chr(160) $+ $si2stats(lamechan)
  did -a $1 1 Read messages (channel, blowfish) $+ $chr(9) $+ $chr(160) $+ $si2stats(bfmsgchan)
  did -a $1 1 Read words (channel) $+ $chr(9) $+ $chr(160) $+ $si2stats(wordchan)
  did -a $1 1 Read messages (query) $+ $chr(9) $+ $chr(160) $+ $si2stats(msgqry)
  did -a $1 1 Read messages (query, lame) $+ $chr(9) $+ $chr(160) $+ $si2stats(lameqry)
  did -a $1 1 Read messages (query, blowfish) $+ $chr(9) $+ $chr(160) $+ $si2stats(bfmsgqry)
  did -a $1 1 Read words (query) $+ $chr(9) $+ $chr(160) $+ $si2stats(wordqry)
  did -a $1 1 Written messages $+ $chr(9) $+ $chr(160) $+ $si2stats(input)
  did -a $1 1 Written messages (lame) $+ $chr(9) $+ $chr(160) $+ $si2stats(inputlame)
  did -a $1 1 Written words $+ $chr(9) $+ $chr(160) $+ $si2stats(wordinput)
  did -a $1 1 Commands executed $+ $chr(9) $+ $chr(160) $+ $si2stats(cmd)
  did -a $1 1 RAWs received $+ $chr(9) $+ $chr(160) $+ $si2stats(raw)
  did -a $1 1 shroudIRC Version $+ $chr(9) $+ $chr(160) $+ $shroudget(version)
  did -a $1 1 mIRC Version $+ $chr(9) $+ $chr(160) $+ $version
  did -a $1 1 Lines of code $+ $chr(9) $+ $chr(160) $+ $lines(script\shroudirc.si2)
  did -a $1 1 Developers Edition $+ $chr(9) $+ $chr(160) $+ $iif($exists(script\shroud.ini), $trans(Yes), $trans(No))
}
on *:dialog:si2stats:*:*:{
  if ($devent == init) {
    mdxdll SetMircVersion $version
    mdxdll MarkDialog $dname $dialog($dname).hwnd
    mdxdll SetControlMDX $dname 1 ListView report showsel single rowselect > mdx\views.mdx
    did -i $dname 1 1 headerdims 270 80
    did -i $dname 1 1 headertext + 0 $trans(Description) $+ $chr(9) $+ + 0 $trans(Value)
    updstatsdlg $dname
  }
  if ($did == 3 && $devent == sclick) {
    if ($input($trans(QSure),yq)) {
      hfree si2stats
      xhmake si2stats
      hsave -o si2stats si2stats.hash
      updstatsdlg $dname
    }
  }
}
dialog tb {
  title ""
  size -1 -1 1404 35
  option pixels
  list 1, 10 4 2000 28, size
  icon 2, 1 5 5 21,  data\tb\drag.bmp, 0, noborder
  text "", 3, 670 10 244 16
}
on *:dialog:tb:init:0:{
  mdxdll SetMircVersion $version
  mdxdll MarkDialog $dname
  mdxdll SetControlMDX $dname 1 ToolBar arrows flat wrap nodivider > mdx\bars.mdx
  mdxdll SetDialog $dname style
  mdxdll SetBorderStyle 1
  did -i $dname 1 1 bmpsize 16 16
  did -i $dname 1 1 pad 12 16
  did -i $dname 1 1 setimage icon small data\tb\blacklist.ico
  did -i $dname 1 1 setimage icon small data\tb\bot.ico
  did -i $dname 1 1 setimage icon small data\tb\feedback.ico
  did -i $dname 1 1 setimage icon small data\tb\kte.ico
  did -i $dname 1 1 setimage icon small data\tb\mlock.ico
  did -i $dname 1 1 setimage icon small data\tb\modules.ico
  did -i $dname 1 1 setimage icon small data\tb\connect.ico
  did -i $dname 1 1 setimage icon small data\tb\settings.ico
  did -i $dname 1 1 setimage icon small data\tb\tile.ico
  did -i $dname 1 1 setimage icon small data\tb\cascade.ico
  did -i $dname 1 1 setimage icon small data\tb\channels.ico
  did -i $dname 1 1 setimage icon small data\tb\about2.ico
  did -i $dname 1 1 setimage icon small data\tb\addrbook.ico
  did -i $dname 1 1 setimage icon small data\tb\walink_play.ico
  did -i $dname 1 1 setimage icon small data\tb\walink_pause.ico
  did -i $dname 1 1 setimage icon small data\tb\walink_prev.ico
  did -i $dname 1 1 setimage icon small data\tb\walink_next.ico
  did -i $dname 1 1 setimage icon small data\tb\logview.ico
  did -i $dname 1 1 setimage icon small data\tb\stats.ico
  did -i $dname 1 1 setimage icon small data\sircsmall.ico
  did -a $dname 1 +ac 7 $chr(9) Dis-/Connect
  did -a $dname 1 +a 0 -
  did -a $dname 1 +a 8 $chr(9) shroudIRC Settings
  did -a $dname 1 +a 11 $chr(9) Channels
  did -a $dname 1 +a 13 $chr(9) Address Book
  did -a $dname 1 +a 0 -
  did -a $dname 1 +a 4 $chr(9) Themes (KTE)
  did -a $dname 1 +a 6 $chr(9) Modules
  did -a $dname 1 +a 0 -
  did -a $dname 1 +a 1 $chr(9) Blacklist
  did -a $dname 1 +a 2 $chr(9) Bot-Central
  did -a $dname 1 +a 18 $chr(9) Logviewer
  did -a $dname 1 +a 19 $chr(9) Statistics
  did -a $dname 1 +a 5 $chr(9) Away
  did -a $dname 1 +a 0 -
  did -a $dname 1 +a 16 $chr(9) Previous
  did -a $dname 1 +a 15 $chr(9) Pause
  did -a $dname 1 +a 14 $chr(9) Play
  did -a $dname 1 +a 17 $chr(9) Next
  did -a $dname 1 +a 0 -
  did -a $dname 1 +a 9 $chr(9) Tile
  did -a $dname 1 +a 10 $chr(9) Cascade
  did -a $dname 1 +a 0 -
  did -a $dname 1 +a 3 $chr(9) Feedback
  did -a $dname 1 +a 12 $chr(9) About
  dockdll DockToolbar $dialog($dname).hwnd
  .signal si2tb_load
}
on *:dialog:tb:sclick:1:{
  var %click $did($dname,1).sel
  if (%click == 2) {
    if ($status != disconnected) { disconnect }
    else { server }
  }
  elseif (%click == 4) {
    setup
  }
  elseif (%click == 5) {
    xasync setup 3 3
  }
  elseif (%click == 6) {
    abook
  }
  elseif (%click == 8) {
    kte.load
  }
  elseif (%click == 9) {
    modloader
  }
  elseif (%click == 11) {
    blacklist
  }
  elseif (%click == 12) {
    sichanlev
  }
  elseif (%click == 13) {
    logview
  }
  elseif (%click == 14) {
    si2statsdlg
  }
  elseif (%click == 15) {
    if ($away) {
      back
    }
    else {
      aw
    }
  }
  elseif (%click == 17) {
    wa_prev
  }
  elseif (%click == 18) {
    wa_pause
  }
  elseif (%click == 19) {
    wa_play
  }
  elseif (%click == 20) {
    wa_next
  }
  elseif (%click == 22) {
    mdi -t
  }
  elseif (%click == 23) {
    mdi -c
  }
  elseif (%click == 25) {
    feedback
  }
  elseif (%click == 26) {
    si2about
  }
}
alias connstate {
  var %s = $gettok($did(tb, 1, 2), 1, 32)
  if ($iif($status == connected, $iif(c !isincs %s, $true), $iif(c isincs %s, $true))) {
    did -o tb 1 2 +a $+ $iif($status == connected, cx) 7 $chr(9) $iif($status == connected, Disconnect, Connect)
  }
}
alias awaystate {
  var %s = $gettok($did(tb, 1, 15), 1, 32)
  if ($iif($away, $iif(c !isincs %s, $true), $iif(c isincs %s, $true))) {
    did -o tb 1 15 +a $+ $iif($away, cx) 5 $chr(9) Away
  }
}
on *:active:*:{
  statecheck
}
alias statecheck {
  if (!$dialog(tb)) { return }
  connstate
  awaystate
}
alias tb.init {
  if ($shroudget(disabletb) == on) { return }
  if ($dialog(tb)) { dialog -c tb }
  dialog -hmv tb tb
  showmirc -s
  statecheck
}
dialog siupdateq {
  title "shroudIRC update"
  size -1 -1 133 68
  option dbu
  icon data\sircsmall.ico, 0
  box "patch", 3, 4 15 125 49
  text "file:", 2, 8 36 12 8
  text "downloading/installing...", 1, 8 24 64 8
  text "", 4, 23 36 100 8
  text "please stand by while shroudIRC is being updated:", 5, 4 4 124 8
  text "", 6, 8 47 116 12
}
on *:dialog:siupdateq:*:*:{
  if ($devent == init) {
    mdxdll MarkDialog $dname $dialog($dname).hwnd
    mdxdll SetControlMDX $dname 6 ProgressBar smooth > mdx\ctl_gen.mdx
    if ($hget(temp, latchedprogress)) { update.progress $hget(temp, latchedprogress) }
    else { update.progess 0 }
    hdel temp latchedprogress
  }
}
alias checkupdates {
  unset %izip
  unset %iupdate
  unset %isetup
  if ($script(shroudirc.si2) == $null) {
    xecho you need the release version of shroudIRC to check for updates
    return
  }
  yecho --
  yecho Checking for updates
  siasyncdownload http://www.shroudirc.net/patches.php?pl= $+ $shroudget(patchlevel) $shortfn($mircdir) $+ patches.lst
}
alias versioninfo {
  xecho You are running shroudIRC version $shroudget(version) $+ , release $iif($shroudget(release) == $null, std, $shroudget(release)) $+ , patchlevel $shroudget(patchlevel)
}
alias update.init {
  yhmake updateq
}
alias update.progess { update.progress $1- }
alias update.progress {
  if ($dialog(siupdateq)) { did -a siupdateq 6 $1 }
  else { hadd -m temp latchedprogress $1 }
}
alias update.add { hadd -m updateq m $+ $suid $$1 }
alias update.run {
  if ($hget(updateq,1).item) {
    if (!$dialog(siupdateq)) { dialog -mv siupdateq siupdateq }
    update.next
  }
}
alias update.next {
  var %upd = $hget(updateq,1).data
  if ($dialog(siupdateq)) { did -a siupdateq 4 %upd }
  if (!%upd) {
    if ($dialog(siupdateq)) { dialog -c siupdateq }
    return
  }
  ifix %upd
  hdel updateq $hget(updateq,1).item
}
alias ifix {
  if ($1 == $null) { return }
  set %thisifix $$1
  yecho --
  yecho Downloading http://www.shroudirc.net/irc/ $+ $$1 to $mircdir $+ $$1 (patch)
  siasyncdownload http://www.shroudirc.net/irc/ $+ $$1 $shortfn($mircdir) $+ $$1
}
alias update.history {
  if ($window(@readme) == $null) {
    siasyncdownload http://www.shroudirc.net/changes.php $shortfn($mircdir) $+ update.html
  }
}
alias update.showhistory {
  if ($exists(update.html)) {
    browser $+(file://,$shortfn($mircdir),update.html) @update
  }
}
dialog -l poll_menu {
  title shroudIRC: $trans(PollTitle)
  size -1 -1 291 50
  option dbu
  edit "", 1, 33 4 254 11, autohs
  edit $trans(ExYes), 2, 33 18 50 11, autohs
  edit $trans(ExNo), 3, 84 18 50 11, autohs
  edit "", 4, 135 18 50 11, autohs
  edit "", 5, 186 18 50 11, autohs
  edit "", 6, 237 18 50 11, autohs
  edit "1", 7, 33 33 42 10, autohs
  button $trans(StartVote), 8, 147 33 84 12, default
  check $trans(ShortResults), 9, 83 33 59 10
  text $trans(Question), 10, 4 5 25 8
  text $trans(Answers), 11, 4 19 25 8
  text $trans(Duration), 12, 4 34 25 8
  button $trans(AbortVote), 13, 233 33 54 12
}
on *:dialog:poll_menu:*:*: {
  if ($devent == sclick) {
    if ($did = 13) {
      if (%vote_runs == on) {
        var %msg = 4,1->0,1 $trans(VoteAborted, " $+ %vote_q $+ ")
        xmsg %vote_channel $stripcx(%vote_channel, %msg)
        .timervote off
        vote_unsetting
      }
    }
    elseif ($did == 8) {
      if ((%vote_runs != on) && ($did(1).text != $null) && (($did(2).text != $null) || ($did(3).text != $null) || ($did(4).text != $null) || ($did(5).text != $null) || ($did(6).text != $null)) && (($did(7).text isnum) && ($did(7).text != $null))) {
        xhmake vote
        set %vote_runs on
        set %vote_q $did(1).text
        set %vote_a1 $did(2).text
        set %vote_a2 $did(3).text
        set %vote_a3 $did(4).text
        set %vote_a4 $did(5).text
        set %vote_a5 $did(6).text
        set %vote_short_res on
        set %vote_channel $active
        set %vote_a1_num 0
        set %vote_a2_num 0
        set %vote_a3_num 0
        set %vote_a4_num 0
        set %vote_a5_num 0
        set %vote_ges_num 0
        set %vote_duration $calc($did(7).text * 60)
        if ($did(9).state == 0) { set %vote_short_res off }
        set %vote_spacer 4,1:0,01
        var %msg = 4,1->0,1 $trans(VoteStarted) $+  " $+ %vote_q $+ " - $trans(VDuration) $+  $did(7).text $+ min.
        xmsg %vote_channel $stripcx(%vote_channel, %msg)
        var %msg = 0,1 $+ $trans(PossibleAnswers) %vote_spacer $iif(%vote_a1 != $null, %vote_a1 %vote_spacer) $iif(%vote_a2 != $null, %vote_a2 %vote_spacer) $iif(%vote_a3 != $null, %vote_a3 %vote_spacer) $iif(%vote_a4 != $null, %vote_a4 %vote_spacer) $iif(%vote_a5 != $null, %vote_a5 %vote_spacer)
        xmsg %vote_channel $stripcx(%vote_channel, %msg)
        .timervote 1 %vote_duration poll_result
      }
      else {
        if (%vote_runs == on) { xechot AlreadyVoting %vote_channel }
        else { xechot VoteNoInput }
      }
    }
  }
}
alias -l poll_result {
  var %msg = 4,1->0,1 $trans(VoteEnd, " $+ %vote_q $+ ", $calc(%vote_duration / 60) $iif(%vote_duration != 60, $trans(MinPlural), $trans(MinSingular)))
  xmsg %vote_channel $stripcx(%vote_channel, %msg)
  if (%vote_short_res == on) {
    short_results
  }
  else {
    long_results
  }
  vote_unsetting
}
alias -l short_results {
  var %msg = 0,1 $+ $trans(Results) %vote_spacer $iif(%vote_a1 != $null," $+ %vote_a1 $+ " ( $+ %vote_a1_num $+ ) %vote_spacer) $iif(%vote_a2 != $null," $+ %vote_a2 $+ " ( $+ %vote_a2_num $+ ) %vote_spacer) $iif(%vote_a3 != $null," $+ %vote_a3 $+ " ( $+ %vote_a3_num $+ ) %vote_spacer) $iif(%vote_a4 != $null," $+ %vote_a4 $+ " ( $+ %vote_a4_num $+ ) %vote_spacer) $iif(%vote_a5 != $null," $+ %vote_a5 $+ " ( $+ %vote_a5_num $+ ) %vote_spacer)
  xmsg %vote_channel $stripcx(%vote_channel, %msg)
}
alias -l long_results {
  if (%vote_ges_num == 0) { set %vote_ges_num 1 }
  res_zeile %vote_a1_num %vote_a1
  res_zeile %vote_a2_num %vote_a2
  res_zeile %vote_a3_num %vote_a3
  res_zeile %vote_a4_num %vote_a4
  res_zeile %vote_a5_num %vote_a5
}
alias -l res_zeile {
  if ($2 != $null) {
    var %vote_pro = $round($calc(($1 * 100) / %vote_ges_num),0)
    var %vote_cent = $round($calc(($1 * $len($shroudget(vstring))) / %vote_ges_num),0)
    if (!$hascblock($active)) {
      xmsg %vote_channel 0,01 $+ $1  $+ $trans($iif($1 != 1, VotesFor, VoteFor)) " $+ $2- $+ " ( $+ %vote_pro $+ % $+ )-( $+ 4,1 $+ $left($shroudget(vstring),%vote_cent) $+ 0,01 $+ $left($shroudget(vstring),$calc($len($shroudget(vstring)) - %vote_cent))) $+ )
    }
    else {
      xmsg %vote_channel  $+ $1  $+ $trans($iif($1 != 1, VotesFor, VoteFor)) " $+ $2- $+ " ( $+ %vote_pro $+ % $+ )
    }
  }
}
alias -l nick_check {
  return $iif($hfind(vote, %1) == $null, $false, $true)
  unset %vote_no
  var %i = 1
  var %vote_max = $hget(vote,0).item
  while (%i <= %vote_max) {
    if ($1 == $hget(vote,%i).item) { return $false }
    inc %i
  }
  return $true
}
alias -l vote_unsetting {
  unset %vote_*
  .hfree -sw vote
}
alias vote { dialog -mv poll_menu poll_menu }
alias who.init {
  xhmake dispwho
  xhmake intwho
}
alias hidenextwho { hinc -m intwho $cid $+ $$1 }
alias dispwho { hadd -m dispwho cmd $+ $hget(dispwho, 0).item $1- }
alias calldispwho {
  var %cnt = $hget(dispwho, 0).item
  var %i = 1
  while (%i <= %cnt) {
    . $hget(dispwho, %i).data $$1-
    inc %i
  }
}
alias whois.init {
  xhmake intwhois
}
alias hidenextwhois { hadd -mu60 intwhois $cid $+ $$1 $$1 }
alias av_xchange {
  return $left($2-, $calc($1 - 1)) $+ ! $+ $right($2-, $calc(- $1))
}
alias av_parseone {
  var %d = $regex($1-,/(\$decode)\(((.+?)\,(.+?)|(.+?))\)/)
  if ($regml(0) >= 2) {
    return $regml(1).pos $iif($decode($regml(2), $iif($regml(4) != $null, $ifmatch, u)), $ifmatch, -2)
  }
  else { return -1 }
}
alias av_sub {
  .echo -q $regex($1, /(\$decode\(.+?\))/)
  return $replace($1, $regml(1), $2)
}
alias av_decode {
  var %txt = $1-
  var %comp = $1-
  var %d = $true
  while (%d) {
    var %decoded = $av_parseone(%txt)
    tokenize 32 %decoded
    var %comp = $av_sub(%comp,$2-)
    if ($gettok(%decoded, 1, 32) != -1) {
      var %txt = $av_xchange($gettok(%decoded, 1, 32), %txt)
    }
    elseif ($gettok(%decoded, 1, 32) == -2) {
      return $1-
    }
    else { var %d = $false }
  }
  return %comp
}
alias xauth.init {
  if (!%xkey) { set %xkey $randqkey }
  :error
  reseterror
}
alias xuserauth {
  var %xpass $?*="X-Password?"
  if (%xpass != $null) {
    .msg X@channels.undernet.org login $1 %xpass
    .timerauth $+ $cid 1 10 doperformc
  }
  else {
    doperformc
  }
}
alias xuseraskauth {
  if ($?!="Auth?" == $true) {
    sixauth
    .timerauth $+ $cid 1 10 doperformc
  }
  else {
    doperformc
  }
}
alias sixgetnick {
  var %nick = $dll(shroud.dll,xgetnick,%xkey)
  if (*shroud.dll* iswm %nick || %nick == 0) { return $null }
  else { return %nick }
}
alias sixispwset { return $dll(shroud.dll,xispwset,%xkey) }
alias sisetxdata { yecho sisetxdata: $shrouddll(setxdata, $1 %xkey) }
alias sixauth {
  var %val = $shrouddll(xauth, %xkey)
  if (%val) { yecho %val }
}
