Peace & Protection 4.00 — File Browser

PeaceProtection4.00v4.0 / PeaceProtection4.00v4.0 / SCRIPT / RAWDISP.MRC

RAWDISP.MRC — 29 KB — Download this file

; #= P&P -rs -2
; ########################################
; Peace & Protection
; Display from common raws (incl. @Whois)
; Should be second-to-last loaded script (for &
; prefixes to work properly with addons, etc.)
; ########################################

;
; Whois
;

raw 311:*:{
  if (%-mwho.nick) { if ($halted == $false) _w.show }
  else unset %-mwho.*
  %-mwho.type = is
  %-mwho.nick = $2
  %-mwho.ident = $3
  %-mwho.host = $4
  %-mwho.real = $6-
  .enable #-whoiscatch #-whoisno
  halt
}
raw 312:*:if ((* isin $3) && (. isin $4) && ($longip($remove($4,$chr(91),$chr(93))) == $null)) { %-mwho.serv = $remove($4,$chr(91),$chr(93)) | %-mwho.servinfo = $5- }  | else { %-mwho.serv = $3 | %-mwho.servinfo = $4- } | halt
raw 313:*:%-mwho.ircop = $3- | halt
raw 317:*:if ($4 isnum) %-mwho.signon = $4 | %-mwho.idle = $3 | halt
raw 318:*:{
  .disable #-whoiscatch #-whoisno
  if (($halted == $false) && (%-mwho.nick != $null)) {
    set -u %.end $iif((* isin $2) || (? isin $2) || (. isin $2),$2)
    _w.show
  }
  else unset %-mwho.*
  halt
}
raw 319:*:{
  if (%-mwho.chanbare == $null) {
    var %chan,%num = 1
    :loop
    %chan = $gettok($3-,%num,32)
    if (-* iswm %chan) %chan = $right(%chan,-1)
    if (($left(%chan,1) isin +@%) && ($mid(%chan,2,1) isin &#)) %chan = $right(%chan,-1)
    %-mwho.chanbare = %-mwho.chanbare %chan
    if (%num < $numtok($3-,32)) { inc %num | goto loop }
  }
  %-mwho.chan = $3-
  halt
}
#-whoisno off
raw 401:*no such*:{
  if (%-mwho.nick) if ($halted == $false) _w.show
  else unset %-mwho.*
  %-mwho.nick = $2
  %-mwho.err = $2 WHOIS
  halt
}
#-whoisno end
alias _w.misc if (%-mwho.misc) %-mwho.misc = %-mwho.misc $+ ; $1- | else %-mwho.misc = $1- | halt
#-whoiscatch off
raw 301:*:%-mwho.away = $3- | halt
raw *:*:if ($numeric isnum) _w.misc $3- | halt
#-whoiscatch end
alias _w.show {
  if (($1 == $null) && ($nick == $server)) {
    var %queue = %-wwq. [ $+ [ %-mwho.nick ] ]
    if (%queue) {
      unset %-wwq. [ $+ [ %-mwho.nick ] ]
      if (%-mwho.err == $null) {
        _juryrig2 %queue
        return
      }
    }
  }

  var %targ,%log = $readini -n $_cfg(window.ini) @Whois log
  if (%log) set -u %.wlog " $+ $logdir $+ %log $+ "
  if ($1) %targ = $1
  elseif ($window(@Whois)) %targ = @Whois
  elseif (($_cfgi(whois.q)) || ((%-whois.src. [ $+ [ %-mwho.nick ] ] == $null) && (%`whois.win == *))) {
    if ($query(%-mwho.nick)) %targ = %-mwho.nick
    elseif ($chat(%-mwho.nick).status == active) %targ = = $+ %-mwho.nick
  }
  if ((%targ == $null) && (%`whois.win == *)) %targ = %-whois.src. [ $+ [ %-mwho.nick ] ]
  unset %-whois.src. [ $+ [ %-mwho.nick ] ]
  if (%targ == $null) %targ = %`whois.win
  if (%-mwho.err) _w.show² %targ * %-mwho.err
  else {
    _recseen whois %-mwho.nick %-mwho.ident $+  $+ %-mwho.host $+  $+ %-mwho.serv $+  $+ %-mwho.nick $+ ! $+ %-mwho.ident $+ @ $+ %-mwho.host $+  $+ $iif(%-mwho.chan,on) $+  $+ $_s2p(%-mwho.chan) $+ * $+ $_s2p(%-mwho.real) 3
    if ($_cfgi(whois.retain)) set -u %.retain $_temp(who) | else unset %.retain
    _w.show² %targ %-mwho.nick %-mwho.ident %-mwho.host $iif(%`whois.nick == on,$:t(%-mwho.nick),$iif(%`whois.nick == hide,$:b($:mc(back,%-mwho.nick)),   ))
  }
}
alias _w.show² {
  var %frount
  if ($1 == @Whois) {
    if ($window(@Whois) == $null) {
      _window 1 -en + @Whois -1 -1 -1 -1 /whois @Whois
      if ($_cfgi(whois.retain)) _loadbuf @Whois $_temp(who)
      if ($_cfgi(whois.focus) != min) %frount = 1
    }
    elseif ($_cfgi(whois.focus) == front) %frount = 1
  }
  if ($2 == *) <no.whois> $1 $3-
  else {
    <disp.whois> $1-
    _recseen serv %-mwho.serv
  }
  unset %-mwho.*
  if (%frount) window -a @Whois
}
alias _w.show³ {
  var %chan,%num = 1,%count = $numtok($2,44)
  :loop
  %chan = $gettok($2,%num,44)
  if ($chr(160) isin %chan) <disp.whois2> $1 %chan fake spaces $3-
  elseif ($strip(%chan) != %chan) <disp.whois2> $1 %chan format codes $3-
  _recseen chan %chan
  _recseen wch %chan  5
  if (%num < %count) { inc %num | goto loop }
}
alias _dispw dispr $1- | if (%.retain) write $ifmatch $:* $2- | if (%.wlog) write $ifmatch $strip($2-)
alias _dispw-div dispr-div $1 | if (%.retain) write $ifmatch $:* $::: | if (%.wlog) write $ifmatch ----------
alias _dispwe _pecho $1- | if (%.retain) write $ifmatch $2- | if (%.wlog) write $ifmatch $strip($2-)
alias _format.chans {
  var %ret,%chan,%deaf,%num = 1,%count = $numtok($1-,32)
  :loop
  %chan = $gettok($1-,%num,32)
  if (-* iswm %chan) { %chan = $right(%chan,-1) | %deaf = 1 }
  if (%ret) %ret = %ret $+ ,
  if (($left(%chan,1) isin +@%) && ($mid(%chan,2,1) isin &#)) %ret = %ret $left(%chan,1) $+ $:s($right(%chan,-1))
  else %ret = %ret $:s(%chan)
  if (%num < %count) { inc %num | goto loop }
  return $iif(%deaf,(deaf)) %ret
}
alias tome {
  if ($window(@Whois) == $null) {
    _window 1 -en + @Whois -1 -1 -1 -1 /whois @Whois
    if ($_cfgi(whois.retain)) _loadbuf @Whois $_temp(who)
  }
  window -a @Whois
}

;
; Server info
;

raw &1:*:disps-div | disps $:i($2-) | halt
raw &2:*:disps $:i($2-) | halt
raw &3:*:disps $:i($2-) | halt
raw &4:*:disps $:i($2-) | disps-div | halt
raw &101:*:disps-div | disps $:i($2-) | halt
raw &102:*:disps $:i($2-) | halt
raw &103:*:disps $:i($2-) | halt
raw &104:*:disps $:i($2-) | disps-div | halt
raw &250:*:disps $:ihn($2-) | halt
raw &251:*:disps-div | disps $:ihn($2-) | halt
raw &252:*:disps $:ihn($2-) | halt
raw &253:*:disps $:ihn($2-) | halt
raw &254:*:disps $:ihn($2-) | halt
raw &255:*:disps $:ihn($2-) | disps-div | halt
raw &256:*:disps-div | disps $:i($2-) | halt
raw &257:*:disps $:i($2-) | halt
raw &258:*:disps $:i($2-) | halt
raw &259:*:disps $:i($2-) | disps-div | halt
raw &263:*:disps $:i($2-) | halt
raw &265:*:disps $:i($2-) | halt
raw &266:*:disps $:i($2-) | halt
raw &351:*:disps $:i($2-) | halt
#-servinfo off
raw &371:*:disps     $:i($2-) | halt
#-servinfo end
raw &371:*:disps-div | disps $:i(Info for  [ $+ [ $:c($nick) ] ] ) | .enable #-servinfo | disps     $:i($2-) | halt
raw 374:*:if ($halted == $false) disps-div | .disable #-servinfo | halt
raw &382:*:disps $:i($2-) | halt
; This raw includes "server pinging"
raw 391:*:{
  var %targ,%sping = %-servping. [ $+ [ $2 ] ],%pinged = $2
  unset %-servping. $+ $2
  if (%sping == $null) {
    if ($_searchtok(%-servmask,$2,32)) {
      %pinged = $gettok(%-servmask,$ifmatch,32)
      %-servmask = $deltok(%-servmask,$ifmatch,32)
      %sping = %-servping. [ $+ [ %pinged ] ]
      unset %-servping. [ $+ [ %pinged ] ]
    }
  }
  if ($gettok(%sping,2,32) == @ServerDetails) {
    if ($window(@ServerDetails) == $null) halt
    var %match = %pinged $+ 	*
    if ($fline(@ServerDetails,%match,1,0)) { rline @ServerDetails $ifmatch $puttok($puttok($line(@ServerDetails,$ifmatch),$round($calc(($ticks - $gettok(%sping,1,32)) / 1000),1),3,9),$2,1,9) | halt }
  }
  elseif (%sping) {
    if ($gettok(%sping,2,32)) %targ = $:n($ifmatch)
    disps %targ $:s(Server Ping) reply of $:s($_dur($calc(($ticks - $gettok(%sping,1,32)) / 1000))) from $:s($2)
    _recseen serv $2
    halt
  }
  if ($halted == $false) { disps Date / time at $:s($2) $+ - $:h($3-) | halt }
}

;
; User info
;

raw &8:& & & Server notice mask *:disps $:n($1) Server notice mask is $:mc(mode,$2,$7) | halt
raw &108:& & & Server notice mask *:disps $:n($1) Server notice mask is $:mc(mode,$2,$7) | halt
raw &221:*:disps $:n($1) Usermode is $:mc(mode,$2-) | halt
#-listsilence off
raw &271:*:disps $:n($2)     $:i($3-) | halt
raw 272:*:if ($halted == $false) { disps $:n($1) $:i(End of silence list) | disps-div } | .disable #-listsilence | halt
#-listsilence end
raw &271:*:disps-div | disps $:n($2) $:i(Silence list) | .enable #-listsilence | disps $:n($2)     $:i($3-) | halt
raw &272:*:disps $:n($1) $:i(No silence list found) | halt
raw &381:*:disps $2- | halt

;
; Registration errors
;

raw &451:*have not reg*:disps $2- $:w((possible bug in script?)) | halt
raw &455:*:disps $2- | halt
raw &462:*:disps $2- | halt
raw &463:*:disps Your host is not allowed to connect here (" $+ $2- $+ ") | halt
raw &464:*pass*incorrect*:disps $:w(Connection password incorrect!) | halt
raw &465:*:disps You are banned from connecting to this server (" $+ $2- $+ ") | halt
raw &484:*connection*restricted*:disps Your connection is $:w(restricted) $+ ! | halt
raw &491:*no*line*host*:disps Your host is not allowed to be an IRC operator (" $+ $2- $+ ") | halt

;
; Inviting users
;

raw &341:*:{
  if ($_ischan($2)) { var %chan = $2,%nick = $3 }
  else { var %chan = $3,%nick = $2 }
  disprs %chan $:cl(%chan) Inviting $:t(%nick) to channel...
  halt
}
raw &342:*summon*to irc*:disps Summoning $:t($2) to IRC... | halt

;
; Error replies
;

raw &402:*no such server*:{
  if (%-nosuch. [ $+ [ $2 ] ] <= 0) <no.serv> $2
  inc -u15 %-nosuch. $+ $2
  unset %-servping. $+ $2
  halt
}
raw &407:*duplicate recipient*:disps Multiple recipients found for $:s($2) (no message sent) | halt
raw &408:*no such service*:disps No such service $:t($3) | halt
raw &409:*no origin*:disps No origin given for server PING / PONG | halt
raw &411:*no recipient give*:disps $2-4 $:s($5-) | halt
raw &412:*no text*:disps No text given to send | halt
raw &413:*no toplevel*:disps No toplevel domain given for $:s($2) (no message sent) | halt 
raw &414:*wildcard*toplevel*:disps Wildcard in toplevel domain for $:s($2) (no message sent) | halt 
raw &416:*too many lines in*output*:disps Your $:s($2) request would return too much data- please try a more specific query | halt
raw &421:*:<no.cmd> $2 | halt
raw &422:*motd*:if ($nick != $server) disps Server error in retrieving Message of the day for $:s($nick) | else disps Server error in retrieving Message of the day | halt
raw &423:*admin*info*:disps Server error in retrieving Administration info for $:s($2) | halt
raw &424:*file error*:disps Error at server (" $+ $2- $+ ") | halt
raw &437:*nick*chan*temp*unavail*:{
  if ($_ischan($2)) disprs $2 $:cl($2) Channel is temporarily unavailable
  else disps $:n($2) Nickname is temporarily unavailable
}
raw &439:*target change too fast*:{
  disprs $2 $iif($_ischan($2),$:cl($2),$:n($2)) The $:b(server) says you can't send to $iif($_ischan($2),$:s($2),$:t($2)) until waiting $:s($9) seconds
  .timer929 1 $9 disprs $2 $iif($_ischan($2),$:cl($2),$:n($2)) You may now send text to $iif($_ischan($2),$:s($2),$:t($2)) 
  halt
}
raw &440:*:disps $2- | halt
raw &444:*user not logged in*:disps $:n($2) User not logged in (cannot summon) | halt
raw &445:*summon*disabled*:disps $:s(SUMMON) command disabled | halt
raw &446:*users*disabled*:disps $:s(USERS) command disabled | halt
raw &461:*not enough param*:disps Not enough parameters for $:s($2) command | halt
raw &481:*not*irc*oper*:disps Sorry, you must be an IRC operator to do that | halt
raw &483:*can*t*kill*server*:disps You cannot $:s(KILL) a server | halt
raw &501:*unknown mode flag*:disps Unknown user mode | halt
raw &502:*change*mode*other*:disps You cannot change or view other users' modes | halt
raw &511:*silence*full*:disps Your $:s(SILENCE) list is full, cannot add $:s($2) | halt

;
; Whowas
;

#-whowasaway off
raw 301:*:%-mwho.away = $3- | halt
raw 312:*:if ((* isin $3) && (. isin $4) && ($longip($remove($4,$chr(91),$chr(93))) == $null)) { %-mwho.serv = $remove($4,$chr(91),$chr(93)) | %-mwho.signoff = $5- }  | else { %-mwho.serv = $3 | %-mwho.signoff = $4- } | halt
#-whowasaway end
raw 314:*:{
  if (%-mwho.nick) { if ($halted == $false) _w.show }
  else unset %-mwho.*
  %-mwho.type = was
  %-mwho.nick = $2
  %-mwho.ident = $3
  %-mwho.host = $4
  %-mwho.real = $6-
  .enable #-whowasaway
  halt
}
raw 369:*:.disable #-whowasaway | if ($halted == $false) _w.show | halt
raw 406:*:{
  if (%-mwho.nick) _w.show
  else unset %-mwho.*
  %-mwho.nick = $2
  %-mwho.err = $2 WHOWAS
  halt
}


;
; 'No such user'
;

raw &401:*failed to deliver*:{
  if ($mid($9,2,1) == $chr(1)) disps Someone left before they could receive the CTCP $:s($remove($9,$chr(1),[,])) you sent them
  else disps The person you sent this message to has left- $:q($left($right($9-,-1),-1))
  halt
}
raw &401:*no such*:{
  if (%-nosuch. [ $+ [ $2 ] ] <= 0) { if ($_ischan($2)) <no.chan> $2 | else <no.user> $2 }
  %-sping.user = $remtok(%-sping.user,$2,32)
  inc -u15 %-nosuch. $+ $2
  halt
}

;
; Away messages
;

raw &301:*:{
  if ($2 != $me) if (%-isaway. [ $+ [ $2 ] ] != $3-) <disp.away> $2-
  set -u60 %-isaway. $+ $2 $3-
  halt
}

;
; Who info (also, IAL update and channel scanning)
;

raw 315:*:{
  var %hide = h $+ $2
  if ($istok(%-whopend,%hide,32)) {
    %-whopend = $remtok(%-whopend,%hide,1,32)
    halt
  }
  var %pend = $gettok(%-whopend,1,32),%pendr = $right(%pend,-1)
  %-whopend = $gettok(%-whopend,2-,32)
  if (/* iswm %pend) {
    if ((%-dwho.num < 1) || (%-dwho.num == $null)) { %-dwho.num = 0 | %-dwho.hops = 0 }
    if ((%-dwho.gone < 1) || (%-dwho.gone == $null)) %-dwho.gone = 0
    if ((%-dwho.op < 1) || (%-dwho.op == $null)) %-dwho.op = 0
    if ((%-dwho.voc < 1) || (%-dwho.voc == $null)) %-dwho.voc = 0
    %-dwho.finis = 1
    _juryrig2 $_p2s(%pend) $2
    halt
  }
  elseif (%pend == hide) { unset %-dwho.* | return }
  elseif ($halted == $false) {
    if ((%-dwho.num < 1) || (%-dwho.num == $null)) { %-dwho.num = 2 | _who.show $iif(%`whois.win == *,-si2,%`whois.win) !! $2 0 }
    else _who.show $iif(%`whois.win == *,-si2,%`whois.win) !! $2 %-dwho.num
    if (%`whois.win == @Whois) window -a @Whois
  }
  unset %-dwho.*
  halt
}
raw 352:*:{
  var %hide = h $+ $2
  if ($istok(%-whopend,%hide,32)) halt
  if ($gettok(%-whopend,1,32) == hide) return
  if (%-dwho.finis) unset %-dwho.*
  if (/* iswm $gettok(%-whopend,1,32)) {
    if ($istok(%!servnick,$6,32)) halt
    if (G isin $7) { inc %-dwho.gone | _series -dwho.away $6 }
    if (* isin $7) _series -dwho.ircop $6
    if (@ isin $7) inc %-dwho.op | elseif (+ isin $7) inc %-dwho.voc
    inc %-dwho.hops $8
    if (%-dwho. [ $+ [ $5 ] ] == $null) {
      %-dwho. [ $+ [ $5 ] ] = $8 $6
      _series -dwho.serv $5
    }
    else _series -dwho. $+ $5 $6
    inc %-dwho.num
  }
  elseif ($halted == $false) _who.show $iif(%`whois.win == *,-si2,%`whois.win) $2-
  halt
}
raw &354:*:_who.show $iif(%`whois.win == *,-si2,%`whois.win) !!! $2- | halt
alias -l _who.show {
  if ($1 == @Whois) {
    if ($window(@Whois) == $null) {
      _window 1 -en + @Whois -1 -1 -1 -1 /whois @Whois
      if ($_cfgi(whois.retain)) _loadbuf @Whois $_temp(who)
    }
    elseif ((%-dwho.num < 1) || (%-dwho.num == $null)) window -n @Whois
  }
  if ((%-dwho.num < 1) || (%-dwho.num == $null)) dispr-div $1
  if ($2 == !!) <end.who> $1 $3-
  elseif ($2 == !!!) dispr $1 $3-
  else <disp.who> $1-
  inc %-dwho.num
}

;
; Nickname errors
;

raw &431:*nick*:disps No nickname given for command | halt
raw &432:*nick*:disps $:n($2) Invalid nickname | halt
raw 433:*nick*:{
  if ($halted == $false) { <nick.in.use> $2 | _ssplay nicktaken }
  %_nickretake = $2
  _recseen user $2
  halt
}
raw 436:*collision*:_alert NICKCOLLISION $:n($2) Nickname collision! | if ($2 == $me) .raw nick dodge $+ $r(0,9) $+ $r(0,9) $+ $r(0,9) | halt
raw &437:*nick*banned*chan*:dispr $2 $:cl($2) Cannot change nickname- You are $:w(banned) | halt
raw 438:*nick*wait*:if ($halted == $false) { _Q.fkey 1 $calc($ctime + $9 + 4) _ctntfc $2 | disps $:n($2) Change to nickname too fast- Delaying $:w($calc($9 + 3)) seconds ( $+ $result to cancel) } | .timer.nickdelay 1 $calc($9 + 3) .raw nick $2 | halt
alias _ctntfc disps $:n($1) Change to nickname cancelled | .timer.nickdelay off

;
; Channel errors
;

raw &403:*no such channel*:<no.exist> $2 | halt
raw &404:*send to chan*:{
  if (%-nospeak. [ $+ [ $2 ] ] <= 0) {
    if (($2 !ischan) || ($chan($2).status == joining)) <no.speak> $2 1
    elseif ((m isin $gettok($chan($2).mode,1,32)) && ($me isreg $2)) <no.speak> $2 2
    elseif ($nick != $server) <no.speak> $2 3
    else <no.speak> $2 4
  }
  inc -u15 %-nospeak. $+ $2
  halt
}
raw &405:*joined too many*:if ($istok(%-repjoin,$2,44)) halt | disprs $2 $:cl($2) Cannot join channel- server limit of $chan(0) channels reached | beep 1 1 | halt
alias -l _chands {
  if (($nick != $server) && ($2 ischan)) {
    if (($me !isop $2) && ($1 == o)) return
    if (($3 != $null) && ($3 !ison $2)) return
    disprs $2 $:cl($2) Probable channel desynch detected
  }
}
raw &441:*:_chands o $3 $2 | <no.on> $3 $2 | halt
raw &442:*:_chands n $2 | <no.you> $2 | halt
raw &443:*already*:disprs $3 $:cl($3) $:t($2) is already on channel $:s((INVITE)) | halt
raw &467:*key already set*:disprs $2 $:cl($2) Channel key already set ( $+ $:s($chan($2).key) $+ ) | halt
raw &468:*server*mode*:disprs $2 $:cl($2) Only servers can change that mode | halt
raw 471:*:if ($istok(%-repjoin,$2,44)) halt | _Q.fkey 1 $calc($ctime + 200) repjoin $2 | if ($halted == $false) { <no.join> $2 1 $result | _ssplay cantjoin } | halt
raw &472:*mode char*:disps Unknown channel mode- $:mc(mode,+ [ $+ $2 ] ) | halt
raw 473:*:if ($istok(%-repjoin,$2,44)) halt | _Q.fkey 1 $calc($ctime + 200) repjoin $2 | if ($halted == $false) { <no.join> $2 2 $result | _ssplay cantjoin } | halt
raw 474:*:if ($istok(%-repjoin,$2,44)) halt | _Q.fkey 1 $calc($ctime + 200) repjoin $2 | if ($halted == $false) { <no.join> $2 3 $result | _ssplay cantjoin } | halt
raw 475:*:{
  if ($istok(%-repjoin,$2,44)) halt
  var %key = $_cfgx(key,$2),%last = %-keyattempt. [ $+ [ $2 ] ]
  if ($findtok(%key,%last,1,32)) var %next = $gettok(%key,$calc($ifmatch + 1),32)
  else var %next = $gettok(%key,1,32)
  if (%next) { _linedance .raw join $2 %next | %-keyattempt. [ $+ [ $2 ] ] = %next }
  elseif (%last) { _Q.fkey 1 $calc($ctime + 200) repjoin $2 | if ($halted == $false) { <no.join> $2 7 $result | _ssplay cantjoin } }
  if (%last == $null) {
    if (%next) { if ($halted == $false) { <no.join> $2 6 $numtok(%key,32) | _ssplay cantjoin } }
    else { _Q.fkey 1 $calc($ctime + 200) repjoin $2 | if ($halted == $false) { <no.join> $2 5 $result | _ssplay cantjoin } }
    unset %-keyattempt. $+ $2
  }
  halt
}
on *:MODE:#:{
  if ((k isin $1) && ($chan($chan).key)) {
    var %key = $_cfgx(key,$chan)
    _cfgxw key $chan $chan($chan).key $gettok($remtok(%key,$chan($chan).key,32),1-4,32)
  }
}
raw 477:*reg*nick*join*:if ($istok(%-repjoin,$2,44)) halt | _Q.fkey 1 $calc($ctime + 200) repjoin $2 | if ($halted == $false) { <no.join> $2 4 $result | _ssplay cantjoin } | halt
raw &478:*ban*list*:disprs $2 $:cl($2) Cannot ban $:s($3) $+ - Ban list is $:w(full) | halt
raw &482:*:_chands o $2 | <no.op> $2 | halt
raw &484:*kick*deop*service*:disprs $3 $:cl($3) Cannot kick or deop $:t($2) (channel service) | halt

;
; MOTD
;

raw &372:*:_domotd $1- | halt
raw &375:*:{
  if ($nick != $server) { disps $:i(Message of the Day for  [ $+ [ $:c($3) ] ] ) | halt }
  disps $:i((retrieving Message of the Day...))
  %_motd.server = $3
  if ($window(@MOTD)) { _dowclose @MOTD | window -c @MOTD }
  _window 2.1 -hlk +l @MOTD $_winpos(10,10,10,10) @MOTD
  unset %_motd.csum
  halt
}
menu @MOTD {
  Reload MOTD:motd | _dowclose @MOTD | window -c @MOTD
}
alias -l _domotd {
  if (($window(@MOTD).state != hidden) || ($nick != $server)) { disps $:i($2-) | halt }
  if ((($2 == -) && ($3 == $null)) || ($2 == $null)) aline @MOTD  
  elseif ($2 == -) aline @MOTD     $3-
  else aline @MOTD     $2-
  inc %_motd.csum $hash($2-,16)
}
alias motd %-motd.req = 1 | motd $1-
raw 376:*:{
  if ($halted) { if ($window(@MOTD).state == hidden) { window -c @MOTD | _dowcleanup @MOTD } | halt }
  var %why
  if (($window(@MOTD).state != hidden) || ($nick != $server)) { disps $:i(End Message of the Day) | halt }
  if (%-motd.req) { unset %-motd.req | %why = $:i(MOTD requested) | goto disp }
  if ($_cfgi(motd.disp) == off) { disps $:i((Message of the Day skipped)) | window -c @MOTD | _dowcleanup @MOTD |  halt }
  if ($_cfgi(motd.disp) == changes) {
    var %old = $readini $_cfg(motd.ini) motd %_motd.server
    if (%old == $null) %why = $:i(MOTD has never been viewed for this server)
    elseif (%old != %_motd.csum) %why = $:i(MOTD has) $:w(changed) $:i(since last viewing!)
    else { disps $:i((Message of the Day has not changed- skipped)) | window -c @MOTD | _dowcleanup @MOTD | halt }
  }
  :disp
  if ($_cfgi(motd.win) == @MOTD) {
    iline @MOTD 1 $:i(Message of the Day for  [ $+ [ $:c(%_motd.server) ] ] )
    if (%why) iline @MOTD 1 %why
    titlebar @MOTD - %_motd.server
    aline @MOTD $:i(End Message of the Day)
    window -aw @MOTD
  }
  else {
    disps-div
    if (%why) disps %why
    disps $:i(Message of the Day for  [ $+ [ $:c(%_motd.server) ] ] )
    var %num = 1
    :loop
    disps $line(@MOTD,%num)
    if (%num < $line(@MOTD,0)) { inc %num | goto loop }
    disps $:i(End Message of the Day)
    disps-div
    window -c @MOTD
    _dowcleanup @MOTD
  }
  if (%_motd.csum) writeini $_cfg(motd.ini) motd %_motd.server %_motd.csum
  unset %_motd.*
  halt
}
raw &377:*:_domotd $1- | halt
raw &378:*:_domotd $1- | halt

;
; Channel info
;

on me:*:JOIN:#:unset %-keyattempt. $+ $chan | %-joining = %-joining $chan | <disp.joinpre> $chan
on *:OP:#:if (($opnick == $me) && (%!net == Undernet) && ((($chan($chan).mode == $null) && ($istok(%-joining,$chan,32))) || (k isincs $chan($chan).mode))) %-joining = %-joining $chan
raw 324:*:{
  if ((k isin  3) && ($chan($2).key)) {
    var %key = $_cfgx(key,$2)
    _cfgxw key $2 $chan($2).key $gettok($remtok(%key,$chan($2).key,32),1-4,32)
  }
  if ($istok(%-joining,$2,32)) {
    %-joining = $remtok(%-joining,$2,1,32)
    %-joining2 = %-joining2 $2
    halt
  }
  if ($istok(%-chaninfo,$2,32)) disprs-div $2
  if ($halted == $false) <disp.mode> $2-
  halt
}
raw &328:*:<disp.url> $2- | halt
raw 329:*:{
  if ($istok(%-joining2,$2,32)) { %-joining2 = $remtok(%-joining2,$2,1,32) | halt }
  if ($halted == $false) <disp.ts> $2-
  halt
}
raw &331:*:<disp.notopic> $2 | unset %-namec.* | halt
raw &332:*:<disp.topic> $2- | unset %-namec.* | halt
raw &333:*:<disp.topicset> $2- | halt
raw 353:*:{
  if ($4 == $null) { set %-namec.ppl -1 | halt }
  if (((%-namec.ppl < 1) || (%-namec.ppl == $null)) && ($istok(%-joining,$3,32) == $false)) {
    if ($istok(%-chaninfo,$3,32)) %-chaninfo = $remtok(%-chaninfo,$3,1,32)
    else disprs-div $3
  }
  inc %-namec.ppl $numtok($4-,32)
  inc %-namec.op $count($4-,@)
  inc %-namec.voc $count($4-,+)
  if ($halted) return
  if ($istok(%-joining,$3,32)) {
    var %show = $_cfgi(show.names)
    if (%show == 0) halt
    if (%show == 2) { <disp.names2> $3 @ $+ $left($:s,3) + $+ $left($:s,3) % $+ $left($:s,3) $4- | halt }
  }
  <disp.names1> $3 @ $+ $left($:s,3) + $+ $left($:s,3) % $+ $left($:s,3) $4-
  halt
}
raw 366:*:{
  if (($istok(%-joining,$2,32) == $false) || ($ial == $false)) col.nicklist $2
  if ($halted) { unset %-namec.* | return }
  if (%-namec.ppl > 0) <disp.users> $2 %-namec.ppl %-namec.op %-namec.voc $calc(%-namec.ppl - %-namec.voc - %-namec.op)
  elseif (%-namec.ppl == -1) <disp.allinvis> $2
  else <disp.nousers> $2
  unset %-namec.*
  halt
}

;
; @Whois popups
;

menu @Whois {
  dclick:query $_grabrec(whois,1)
  $_poprec(wch,1):j $_grabrec(wch,1)
  $_poprec(wch,2):j $_grabrec(wch,2)
  $_poprec(wch,3):j $_grabrec(wch,3)
  $_poprec(wch,4):j $_grabrec(wch,4)
  $_poprec(wch,5):j $_grabrec(wch,5)
  -
  $_poprec(whois,1,$numtok(%>wch,32))
  .User info
  ..Whois:whois $_grabrec(whois,1)
  ..Extended whois:ew $_grabrec(whois,1)
  ..User central...:uwho $_grabrec(whois,1)
  ..Address book...:abook $_grabrec(whois,1)
  ..-
  ..DNS:dns $gettok($_refsufn(whois,1),2,127)
  ..Hostmask:host $gettok($_refsufn(whois,1),4,127)
  ..-
  ..Server ping:sping $gettok($_refsufn(whois,1),3,127)
  .DCC
  ..Chat:dcc chat $_grabrec(whois,1)
  ..Chat to IP:dcc chat $gettok($_refsufn(whois,1),2,127)
  ..-
  ..Send:dcc send $_grabrec(whois,1)
  ..Send to IP:dcc send $gettok($_refsufn(whois,1),2,127)
  ..-
  ..$_dynpop($iif(($istok($level($gettok($_refsufn(whois,1),4,127)),=dcc,44)) && ($istok($level($gettok($_refsufn(whois,1),4,127)),=auth,44) == $false),1,0)) Authorize for DCCs:auth -t $gettok($_refsufn(whois,1),4,127)
  ..$_dynpop($iif(($istok($level($gettok($_refsufn(whois,1),4,127)),=dcc,44)) && ($istok($level($gettok($_refsufn(whois,1),4,127)),=auth,44)),1,0)) Temp authorize:auth -t $gettok($_refsufn(whois,1),4,127) 15
  .Ping:ping $_grabrec(whois,1)
  .Query:query $_grabrec(whois,1)
  .-
  .$_dynpop($iif($level($gettok($_refsufn(whois,1),4,127)) > 1,1,0)) Userlist...:user $gettok($_refsufn(whois,1),4,127)
  .$_dynpop($iif($_grabrec(whois,1) isnotify,1,0)) Notify...:notif $gettok($_refsufn(whois,1),4,127)
  .-
  .Copy:clipboard $_grabrec(whois,1) is $gettok($_refsufn(whois,1),1,127) $+ @ $+ $gettok($_refsufn(whois,1),2,127) $_p2s($gettok($_refsufn(whois,1),5-,127))
  $_poprec(whois,2,$numtok(%>wch,32))
  .User info
  ..Whois:whois $_grabrec(whois,2)
  ..Extended whois:ew $_grabrec(whois,2)
  ..User central...:uwho $_grabrec(whois,2)
  ..Address book...:abook $_grabrec(whois,2)
  ..-
  ..DNS:dns $gettok($_refsufn(whois,2),2,127)
  ..Hostmask:host $gettok($_refsufn(whois,2),4,127)
  ..-
  ..Server ping:sping $gettok($_refsufn(whois,2),3,127)
  .DCC
  ..Chat:dcc chat $_grabrec(whois,2)
  ..Chat to IP:dcc chat $gettok($_refsufn(whois,2),2,127)
  ..-
  ..Send:dcc send $_grabrec(whois,2)
  ..Send to IP:dcc send $gettok($_refsufn(whois,2),2,127)
  ..-
  ..$_dynpop($iif(($istok($level($gettok($_refsufn(whois,2),4,127)),=dcc,44)) && ($istok($level($gettok($_refsufn(whois,2),4,127)),=auth,44) == $false),1,0)) Authorize for DCCs:auth -t $gettok($_refsufn(whois,2),4,127)
  ..$_dynpop($iif(($istok($level($gettok($_refsufn(whois,2),4,127)),=dcc,44)) && ($istok($level($gettok($_refsufn(whois,2),4,127)),=auth,44)),1,0)) Temp authorize:auth -t $gettok($_refsufn(whois,2),4,127) 15
  .Ping:ping $_grabrec(whois,2)
  .Query:query $_grabrec(whois,2)
  .-
  .$_dynpop($iif($level($gettok($_refsufn(whois,2),4,127)) > 1,1,0)) Userlist...:user $gettok($_refsufn(whois,2),4,127)
  .$_dynpop($iif($_grabrec(whois,2) isnotify,1,0)) Notify...:notif $gettok($_refsufn(whois,2),4,127)
  .-
  .Copy:clipboard $_grabrec(whois,2) is $gettok($_refsufn(whois,2),1,127) $+ @ $+ $gettok($_refsufn(whois,2),2,127) $_p2s($gettok($_refsufn(whois,2),5-,127))
  $_poprec(whois,3,$numtok(%>wch,32))
  .User info
  ..Whois:whois $_grabrec(whois,3)
  ..Extended whois:ew $_grabrec(whois,3)
  ..User central...:uwho $_grabrec(whois,3)
  ..Address book...:abook $_grabrec(whois,3)
  ..-
  ..DNS:dns $gettok($_refsufn(whois,3),2,127)
  ..Hostmask:host $gettok($_refsufn(whois,3),4,127)
  ..-
  ..Server ping:sping $gettok($_refsufn(whois,3),3,127)
  .DCC
  ..Chat:dcc chat $_grabrec(whois,3)
  ..Chat to IP:dcc chat $gettok($_refsufn(whois,3),2,127)
  ..-
  ..Send:dcc send $_grabrec(whois,3)
  ..Send to IP:dcc send $gettok($_refsufn(whois,3),2,127)
  ..-
  ..$_dynpop($iif(($istok($level($gettok($_refsufn(whois,3),4,127)),=dcc,44)) && ($istok($level($gettok($_refsufn(whois,3),4,127)),=auth,44) == $false),1,0)) Authorize for DCCs:auth -t $gettok($_refsufn(whois,3),4,127)
  ..$_dynpop($iif(($istok($level($gettok($_refsufn(whois,3),4,127)),=dcc,44)) && ($istok($level($gettok($_refsufn(whois,3),4,127)),=auth,44)),1,0)) Temp authorize:auth -t $gettok($_refsufn(whois,3),4,127) 15
  .Ping:ping $_grabrec(whois,3)
  .Query:query $_grabrec(whois,3)
  .-
  .$_dynpop($iif($level($gettok($_refsufn(whois,3),4,127)) > 1,1,0)) Userlist...:user $gettok($_refsufn(whois,3),4,127)
  .$_dynpop($iif($_grabrec(whois,3) isnotify,1,0)) Notify...:notif $gettok($_refsufn(whois,3),4,127)
  .-
  .Copy:clipboard $_grabrec(whois,3) is $gettok($_refsufn(whois,3),1,127) $+ @ $+ $gettok($_refsufn(whois,3),2,127) $_p2s($gettok($_refsufn(whois,3),5-,127))
  -
  Configure:config wh
}

;
; Away log stuff
;
#_awaylog off
on &^*:OPEN:?:*:if ((%`awaylog.close) && (%`awaylog.msg)) { %_timedclose = $addtok(%_timedclose,$nick,32) | .timer.dtqc 1 $iif(%`awaylog.close == 1,20,0) _dtqc }
on &^*:TEXT:*:?:while.away 1 < $+ $nick $+ > $1-
on &^*:ACTION:*:?:while.away 2 * $nick $1-
alias -l while.away {
  ; Logs any msg if logging is on, UNLESS query is open, not closing, and we close queries
  if ((%`awaylog.msg) && ((%`awaylog.close == 0) || ($query($nick) == $null) || ($istok(%_timedclose,$nick,32)))) _awaylog ? $1-
  _away.remind
}
on &^*:NOTICE:*:*:{
  if (($1 === DCC) && (($2 == Chat) || ($2 == Send))) return
  if (@* iswm $target) _awaylog ! 3 $target $+  - $+ $nick $+ - $1-
  elseif (%.opnotice) _awaylog ! 3 @ $+ %.opnotice $+  (?) - $+ $nick $+ - $1-
  else _awaylog ! 4 - $+ $nick $+ - $1-
}
on &*:INVITE:#:_awaylog @ 10 ( $+ $chan $+ ) »»» Invited by $nick
; Nick/highlight in channel
on &^*:TEXT:*:#:_doahl 13 < $+ $nick $+ > $strip($1-)
on &^*:ACTION:*:#:_doahl 14 * $+ $nick $strip($1-)
#_awaylog end
on &^*:TEXT:*:#:if (%!away) _doaww $1-
on &^*:ACTION:*:#:if (%!away) _doaww $1-
on &^*:TEXT:*:?:if (%!away) _away.remind
on &^*:ACTION:*:?:if (%!away) _away.remind

;
; CTCP stuff
;
ctcp *:SOUND:return
#doaccess off
ctcp &175:DO:{
  $2-
  set -u %.ctcp.reply 0
  _do.rctcp $1-
}
#doaccess end
ctcp &*:*:_do.rctcp $1-
on &*:CTCPREPLY:*:_do.creply $1-