### deep.irc script for bitchx by panasync
### written by shade (sk@dhp.com)   

### stolen code: original fixsize alias by zircon 
### stolen code: country lookup table by srfrog
### stolen code: repeat kicker stolen from bitZ by pent blatently

### as far as stolen code goes, if you wanna use one of my functions,
### go right ahead, just gimmie credit, as i give credit for what i use.

### check for bitchx and previously loaded script
if (!bitchx()) {echo >>> deep requires BitchX.  get your copy from ftp.thirdwave.net.;//si no bitchx = no deep}
if (deep) {echo >>> never load deep more than once, dumbfuck :> now yer fuxed.}
if (V < 19961228) {echo >>> you need a newer version of bitchx (69* or better);//quit my bitchx is old and senile}

### colors
^assign blnk [5m
^assign cl [0m
^assign cl2 [1m
^assign blk [0;30m
^assign red [0;31m
^assign grn [0;32m
^assign yel [0;33m
^assign blu [0;34m
^assign mag [0;35m
^assign cyn [0;36m
^assign wht [0;37m
^assign hblk [1;30m
^assign hred [1;31m
^assign hgrn [1;32m
^assign hyel [1;33m
^assign hblu [1;34m
^assign hmag [1;35m
^assign hcyn [1;36m
^assign hwht [1;37m
^assign bblk [40m
^assign bred [41m
^assign bgrn [42m
^assign byel [43m
^assign bblu [44m
^assign bmag [45m
^assign bcyn [46m
^assign bwht [47m

### variable declarations
@deep=[\(deep:0.99gamma\)]
@clinfo=[too much information]
@ccol=[:]
@funk=[ð]
do ^assign fsend ${hblk}:${cyn}:${hcyn}:${cl}
do ^assign G ${hblk}:${mag}:${hmag}:${cl}
@deepver=[$deep by shade]
@deeppath=[$HOME/.deep]
@memofile=[$deeppath/deep.memos]
@deepsave=[$deeppath/deep.setup]
@dlogfile=[$deeppath/deep.log]
@deephelp=[$deeppath/deep.help]
@defawaymsg=[there's nothing like giving the game away]
@defbackmsg=[still lookin' for that old fire]
@myemailaddy=[$X]
@rkicker=[on]
@idleawaytime=[10]
@awaylog=[off]
@prtype=[norm]
@autocsave=[on]
@dtog=[1]
@repeatlimit=[2]
@donscroll=[0]
@nscnt=[0]
@ndir=[0]
@fkey[1]=[dhelp]
@fkey[2]=[user]
@fkey[3]=[sv]
@fkey[4]=[cdcc plist]
@fkey[5]=[readlog]
@fkey[6]=[names $C]
@fkey[7]=[scanc]
@fkey[8]=[scann]

### client setup
set hard_uh_notify on
do set show_numerics_str $G
set auto_away off
set show_channel_names off
set cdcc_prompt $G %K[%ccdcc%K]
set help_prompt off
set mode_stripper on
set kick_if_banned off
set http_grab on
set deop_on_deopflood 20
set kick_on_deopflood 20
set kick_on_kickflood 10
set kick_on_nickflood 10
set kick_on_pubflood 5
set deopflood_time 5
set kickflood_time 5
set nickflood_time 5
set pubflood_time 5
set flood_after 15
set flood_rate 15

### global aliases and functions
alias deecho echo $G $0-
alias servah {
  if (S) {@function_return=[$S]} {@function_return=none}}
alias botorfriend {
  if (checkbot($0 $1)) {
    @function_return=[bot]}
   {@function_return=[friend}}
alias namecolor {
  if ([$0]>=[5]) {
    @function_return=[${hblk}]}
   {@function_return=word($0 ${hcyn} ${cyn} ${hblu} ${blu} ${hblk})}}
alias fixtime {
  @boog=left(2 $0)
  if ([$[1]boog]!=[1]) {
    @boog=right(1 $boog)}
  if (boog < 12) {
    @function_return=[$boog$mid(2 3 $0)am]}
   {@boog=boog - 12
    @function_return=[$boog$mid(2 3 $0)pm]}}
alias fixfloattime {
  @bleargh=[$0]
  if (bleargh < 1) {
    @bleargh=bleargh * 1000
    @bleh=[ms]}
   {@bleh=[s]}
  @function_return=[$bleargh$bleh]}
alias csort {
  @newsort=[]
  @csort1=[$0-]
  @csort2=tolower($strip([]-/_\^~ $csort1))
  @csort2=sar(g/0/o/$csort2)
  @csort3=sort($csort2)
  fe ($csort3) sortme {
    @push(newsort $copattern($sortme csort2 csort1))}
  @function_return=weed($newsort)}
alias cstrip {
  @stripit=[$0-]
  fe ($scolors) stripcolor {
    @stripit=sar(g/$stripcolor//$stripit)}
  @function_return=stripansi($stripit)}
alias ccenter {
  @ccen=[$1-]
  @csize=[$0]
  @tempc1=cstrip($ccen)
  @tempc=pad(-$csize $center($csize $tempc1))
  @function_return=sar(g/$tempc1/$ccen/$tempc)}
alias chquiet {
  @tempniqs=[]
  fe ($onchannel($0)) niq {
  if (!isvoice($0 $niq)) @push(tempniqs $niq)}
  @function_return=[$tempniqs]}
alias chvoice {
  @tempniqs=[]
  fe ($onchannel($0)) niq {
  if (isvoice($0 $niq)) @push(tempniqs $niq)}
  @function_return=[$tempniqs]}
alias chusers {
  @tempniqs=[]
  fe ($onchannel($0)) niq {
  if (checkuser($niq!$uhost($niq) $0)) @push(tempniqs $niq)}
  @function_return=[$tempniqs]}
alias chshits {
  @tempniqs=[]
  fe ($onchannel($0)) niq {
  if (checkshit($niq!$uhost($niq) $0)) @push(tempniqs $niq)}
  @function_return=[$tempniqs]}
alias chbots {
  @tempniqs=[]
  fe ($onchannel($0)) niq {
  if (checkbot($niq!$uhost($niq) $0)) @push(tempniqs $niq)}
  @function_return=[$tempniqs]}
alias chnonusers {
  @tempniqs=[]
  fe ($onchannel($0)) niq {
  if ((!checkuser($niq!$uhost($niq) $0))&&(!checkbot($niq!$uhost($niq) $0))) @push(tempniqs $niq)}
  @function_return=[$tempniqs]}
alias safe {
  @function_return=strip(\;\(\)*/\\\{\}$$~`|'\" $0-)}
alias weed {
  @tempweed=[]
  fe ($0-) weedit {
    if (!pattern($weedit $tempweed)) {
      @push(tempweed $weedit)}}
  @function_return=[$tempweed]}
alias mysend {
  if ([$[1]0]==[#]) { 
    send $cstrip($1-)}
   {do msg $0 $$1-}} 
alias checkvoice {
  if (isvoice($1 $0)) {@function_return=[+$0]} {@function_return=[$0 ]}}
alias country { 
  if (isalpha($fixhost($0))) {
  @cnt=mid(${rindex(. $fixhost($0))+1} 5 $fixhost($0))
  if (domain[$cnt]) {@function_return=[${hblk}\[${hwht}$domain[$cnt]${hblk}\]}{@function_return=[]}}
 {@function_return=[]}}
alias noident {
  if ([$[1]0]==[~]) {@function_return=[${hblk}\[${hwht}no ident${hblk}\]${cl}} {@function_return=[]}}
alias comchan {
  @tchans=mychannels()
  @common=[]
  @comuser=[$0]
  fe ($tchans) curchan {
    if (onchannel($comuser $curchan)) {@common=[$common $curchan]}}
  @function_return=[$common]}
alias fixc {@function_return=center(34 $0-)}
alias fixctcp {
  @fixor=[$0-]
  @function_return=toupper($fixor)
  if (([$word(1 $fixor)]==[ ])||([$word(1 $fixor)]==[])) {@function_return=[$word(0 $fixor)]}
  if ([$word(0 $fixor)]==[PING]) {@function_return=[PING]}}
alias fixcnick {if ([$0]==[$N]) {@function_return=[you]} {@function_return=[$0]}}
alias fixeta {
  if ([$strlen($0)]==[1]) {@function_return=[0$0]}{@function_return=[$0]}}
alias fixhost {
  if (isdigit($0)) {
    if (iptoname($0)) {@function_return=[$iptoname($0)]} {@function_return=[$0]}}
 {@function_return=[$0]}}
alias fixihr {if ([$0]) {@function_return=[$0hr$plural($0) ]}}
alias fiximn {if ([$0]) {@function_return=[$0min$plural($0) ]}}
alias fixisc {if ([$0]) {@function_return=[$0sec$plural($0)]}}
alias fixip {
  @function_return=[$useronly($0)@$fixhost($hostonly($0))]}
alias fixsize {
  if ([$0]) {
    @ sz1 = [$0]
    @ sz2 = sz1 / 1024
    if (sz2 > 0) {
      if (sz2 >= 1024) {
        @ function_return = [${sz2 / 1024}mb]}
       {@ function_return = [${sz2}kb]}}
     {@ function_return = [${sz1}b]}}
  {@ function_return = [0b]}}
alias fixuptime {@fuxed1=[];@fuxed2=[];@fuxed3=[]
  if ([$0]!=[0d]) {@fuxed1=[$0 ]}
  if ([$1]!=[0h]) {@fuxed2=[$1 ]}
  @fuxed3=[$2]
  @fuxed=[$fuxed1$fuxed2$fuxed3]
  if ([$right(1 $fuxed)]==[ ]) {@crapp=strlen($fuxed);@crapp=crapp-2;@fuxed=[$left($crapp $fuxed)]}
  @function_return=[ ${HBLK}- ${HBLU}up:${CYN}$fuxed]}
alias fuckup {@function_return=reverse($rot13($encode($0-)))}
alias fuxit {@function_return=[$0!$1]}
alias hostonly {
  @function_return=mid(${index(@ $0)+1} ${@0-index(@ $0)+1} $0)}
alias mytime {
  @tmptime=strip([] $0)
  if (left(1 $tmptime)==[0]) {@tmptime=[ $right(6 $tmptime)]} 
  @function_return=[${HBLK}[${HBLU}$strftime($time() %x) ${HBLK}@ ${HBLU}$tmptime${HBLK}]${CL}]}
alias newuptime {
  @function_return=tdiff(${time() - F})}
alias nospace {
  @function_return=sar(g/ //$0-)}
alias percentbar {
  @num = [$0]
  if (num >= 90) {@bar=["%K±²Û%6%K²±° %C°±²%n"]}
  if (num < 90 && num >= 80) {@bar=["%K±²Û%6%K²±° %C°±%0%K°%n"]}
  if (num < 80 && num >= 70) {@bar=["%K±²Û%6%K²±° %C°%0%K°°%n"]}
  if (num < 70 && num >= 60) {@bar=["%K±²Û%6%K²±° %0%K°°°%n"]}
  if (num < 60 && num >= 50) {@bar=["%K±²Û%6%K²±°%0%K°°°°%n"]}
  if (num < 50 && num >= 40) {@bar=["%K±²Û%6%K²±%0%K°°°°°%n"]}
  if (num < 40 && num >= 30) {@bar=["%K±²Û%6%K²%0%K°°°°°°%n"]}
  if (num < 30 && num >= 20) {@bar=["%K±²Û°°°°°°°%n"]}
  if (num < 20 && num >= 10) {@bar=["%K±²°°°°°°°°%n"]}
  if (num < 10) {@bar=["%K±°°°°°°°°°%n]}
  @function_return=cparse($bar)}
alias plural {if ([$0]!=[1]) {@function_return=[s]}}
alias unfuckup {@function_return=decode($rot13($reverse($0-)))}
alias useronly {
  @function_return=left(${index(@ $0)} $0)}

### status bar
do set status_channel ${hblk}\(${cyn}%C
do set status_lag ${hblk}\(${hcyn}lag${hblk}:${cyn}%L${hblk}\)${cl}
do set status_chanop ${hblk}@
do set status_away  ${hblk}[${cyn}away${hblk}]${cl}
do set status_clock ${hcyn}time${hblk}:${cyn}%T${cl}
do set status_mail ${hblk}\(${hblu}mail${hblk}:${blu}%M${hblk}\)${cl} 
do set status_mode  ${hblk}[${cyn}+${hcyn}%+${hblk}]${cl}
do set status_oper ${hcyn}*
do set status_voice ${hblk}+
do set status_umode  ${hblk}[${blu}+${hblu}%#${hblk}]${cl}
do set status_users  ${hcyn}o${hblk}:${cyn}%! ${hcyn}n${hblk}:${cyn}%! ${hcyn}i${hblk}:${cyn}%! ${hcyn}v${hblk}:${cyn}%!${hblk}\) ${cl}
do set status_query ${hblk}\(${hcyn}query${hblk}:${cyn}%Q${hblk}\)${cl}
do set status_user5 $deep 
set -status_user4
do window set status_channel ${hblk}\(${cyn}%C
do window set status_lag ${hblk}\(${hcyn}lag${hblk}:${cyn}%L${hblk}\)${cl}
do window set status_chanop ${hblk}@
do window set status_clock ${hcyn}time${hblk}:${cyn}%T${cl}
do window set status_mail ${hblk}\(${hblu}mail${hblk}:${blu}%M${hblk}\)${cl} 
do window set status_mode  ${hblk}[${cyn}+${hcyn}%+${hblk}]${cl}
do window set status_oper ${hcyn}*
do window set status_voice ${hblk}+
window set status_hold [-press space-]
do window set status_umode  ${hblk}[${blu}+${hblu}%#${hblk}]${cl}
do window set status_users  ${hcyn}o${hblk}:${cyn}%! ${hcyn}n${hblk}:${cyn}%! ${hcyn}i${hblk}:${cyn}%! ${hcyn}v${hblk}:${cyn}%!${hblk}\) ${cl}
do window set status_user5 $deep
do window set status_away  ${hblk}[${cyn}away${hblk}]${cl}
do window set status_query ${hblk}\(${hcyn}query${hblk}:${cyn}%Q${hblk}\)${cl}
do window set status_server ${hblk}\(${hcyn}server${hblk}:${cyn}$servah()${hblk}\)${cl}
do set status_server ${hblk}\(${hcyn}server${hblk}:${cyn}$servah()${hblk}\)${cl}
window set -status_user4

### binds
bind ^X switch_channels
bind ^Z stop_irc
bind meta1-I parse_command dcctoggle
bind meta3-A parse_command dokey 1
bind meta3-B parse_command dokey 2
bind meta3-C parse_command dokey 3
bind meta3-D parse_command dokey 4
bind meta3-E parse_command dokey 5
bind meta3-7 parse_command dokey 6
bind meta3-8 parse_command dokey 7
bind meta3-9 parse_command dokey 8
alias dokey {
  ^bind ~ nothing
  $fkey[$0]
  ^timer 1 ^bind ~ self_insert}

### make irc windows like screen
if (!totalwindows) {@totalwindows=1}
if (!windowuptimes) {@windowuptimes=time()}
@windowshell=[$shell]
alias usefultime {
  @emit=stime($time())
  @function_return=[$word(0 $emit), $word(1 $emit) $word(2 $emit) $word(4 $emit) : $Z]}

bind ^W meta5_character
bind meta5-p parse_command _goto_previous_window
bind meta5-c parse_command _create_new_window
bind meta5-h parse_command dhelp window
bind meta5-k parse_command _kill_current_window
bind meta5-l parse_command clear;reset;statusecho window $winnum() has been reset
bind meta5-n parse_command _goto_next_window
bind meta5-u parse_command _show_window_uptime
bind meta5-w parse_command window list
bind meta5-s parse_command _create_shell_window
bind meta5-v parse_command _show_version_info
bind meta5-? parse_command dhelp window
bind meta5-1 parse_command _winswap 1
bind meta5-2 parse_command _winswap 2
bind meta5-3 parse_command _winswap 3
bind meta5-4 parse_command _winswap 4
bind meta5-5 parse_command _winswap 5
bind meta5-6 parse_command _winswap 6
bind meta5-7 parse_command _winswap 7
bind meta5-8 parse_command _winswap 8
bind meta5-9 parse_command _winswap 9

alias _show_version_info {
  statusecho $J/$deep - server version $version()}
alias _show_window_uptime {
  statusecho $usefultime() - window $winnum() created $nospace($tdiff2(${time() - word(${winnum() - 1} $windowuptimes)})) ago}
alias _goto_next_window {
  if (totalwindows > 1) {
    @lastwindow=winnum()
    window next
    if (winnum() == 1) {
      ^window split on}
    if (lastwindow != winnum()) {
      statusecho window $winnum() activated}}
 {statusecho no other windows active}}
alias _goto_previous_window {
  if (totalwindows > 1) {
    @lastwindow=winnum()
    window previous
    if (winnum() == 1) {
      ^window split on}
    if (lastwindow != winnum()) {
      statusecho window $winnum() activated}}
 {statusecho no other windows active}}
alias _winswap {
  if (pattern($0 $winrefs())) {
    @oldwindow=winnum()
    do window swap $0
    if (winnum() == 1) {
      ^window split on}
    if (oldwindow != winnum()) {
      statusecho window $winnum() activated}}
   {statusecho window $0 not active}}
alias _create_shell_window {
  window new hide
  @totalwindows=totalwindows + 1
  @push(windowuptimes $time())
  window swap last
  ^window double off
  @push(windowshells $winnum())
  do exec -window -name shell$winnum() $windowshell
  do ^on ^exec_exit 'shell$winnum() 0' {
    _kill_current_window}
  do ^query %shell$winnum()
  do ^window set status_format1  %> $${hblk}\(${cyn}%T${hblk}\)   $${hblk}\(${hcyn}$windowshell${hblk}\)  $${hblk}\(${cyn}$X${hblk}\) $${cl}$broxed_bx
  statusecho created new shell [$windowshell] window $winnum()}
alias _create_new_window {
  window new hide
  @totalwindows=totalwindows + 1
  @push(windowuptimes $time())
  window swap last
  ^window double on
  ^window split on
  statusecho created new window $winnum()}
alias _kill_current_window {
  if (winnum()!=1) {
    @killored=winnum()
    @totalwindows=totalwindows - 1
    @windowuptimes=notw(${winnum() - 1} $windowuptimes)
    if (pattern($killored $windowshells)) {
      do ^exec -kill %shell$killored
      ^on -exec_exit '%shell$killored 0' #
      @windowshells=remw($winnum() $windowshells)}
    ^window set -status_user7
    window kill
    if (winnum() == 1) {
      ^window split on}
    statusecho window $killored killed - window $winnum() activated}
 {statusecho window 1 cannot be killed}}

### event handler
on #-send_msg 23 * {
  ^hook rel_add relsm $0 $fsend ${hblk}[${hcyn}msg${hblk}/${cyn}$0${hblk}] ${cl}$mircansi($1-)}
on #-send_notice 23 * {
  ^hook rel_add relsn $0 $fsend ${hblk}[${hcyn}notice${hblk}/${cyn}$0${hblk}] ${cl}$mircansi($1-)}
on #-ctcp_reply 23 * {
  ^hook rel_add relcr $0 $G ${hblk}[ ${hblk}$funk ${hgrn}$0 ${hblk}$funk ${grn}ctcp reply/${hblk}${hgrn}$1 ${hblk}]: ${cl}$2-}
on #-wallop 23 * {
  ^hook rel_add relw $0 ${hblk}[${hgrn}!${grn}$0${hblk}:${grn}$1${hgrn}!${hblk}] ${cl}$mircansi($2-)}
on #-msg 23 * {
  ^hook dlog msg $0: $mircansi($1-)
  ^hook rel_add relm $0 ${hblk}[${cyn}$0${hblk}] ${cl}$1- ${hblk}[${cyn}$fixip($userhost())${hblk}]}
on #-invite 23 * {
  ^hook dlog invite recieved invite to $1 from $0
  ^hook rel_add reli $0 ${hblk}[ $funk ${cyn}$0 ${hblk}$funk ${hcyn}invite${hblk}/${cyn}$1 ${hblk}]:${cl}}
on #-dcc_connect 23 * {
  ^hook dlog dconnect dcc connection: $0-}
on #-ctcp 23 * {
  if (fixcnick($1)==[you]) {
    ^hook dlog ctcp CTCP $fixctcp($2-) request recieved from $0} 
  ^hook rel_add relc $0 ${hblk}[ $funk ${grn}$0 ${hblk}$funk ${hgrn}ctcp $fixctcp($2-) request${hblk}/${grn}$fixcnick($1) ${hblk}]: \(${cl}$fixip($userhost())${hblk}\)}
on #-notice 23 * {^hook dlog notice $0: $mircansi($1-)
  ^hook rel_add reln $0 ${hblk}-${hblu}$0${hblk}- $mircansi($1-)}
on #-dcc_lost 23 * {
  ^hook dlog lostdcc dcc connection: $0-}
on #-connect 23 * {
  ^hook dlog server connection established to $0-}
on #-disconnect 23 * {
  ^hook dlog server lost connection to $0-}
on #-kick 23 * {
  if ([$0]==[$N]) {
    ^hook dlog kick kicked from $2 by $1: $3-}}
on #-msg_group 23 * {
  ^hook dlog groupmsg $0/$1: $2-}
on #-ar_public 23 * {
  ^hook dlog arpublic \($0/$1\) $2-}
on #-ar_public_other 23 * {
  ^hook dlog arpublic \($0/$1\) $2-}
on #-dcc_error 23 * {
  ^hook dlog derror dcc error: $0-}
on #-join 23 * {if ([$0]==[$N]) {
  ^hook dlog join joined channel $1}}
on #-dcc_chat 23 * {
  ^hook dlog dccchat $0: $1-
  ^hook rel_add reld $0 ${hblk}[${hcyn}$0${hblk}\(${cyn}dcc${hblk}\)] ${cl}$mircansi$1-}
on #-send_dcc_chat 23 * {
  ^hook rel_add relsd $0 ${hblk}[=${mag}$0${hblk}=]: ${cl}$mircansi($1-)}
on #-mode_stripped 23 * {
  if (pattern($N $2-)) {
  ^hook dlog mode mode change on $1 by $0: $2-}}
alias ctcp {
  if ([$1]) {
    ^hook rel_add relsc $0 $fsend ${hblk}[${hcyn}ctcp${hblk}/${cyn}$0${hblk}]: $toupper($1-)
    echo $fsend ${hblk}[${hcyn}ctcp${hblk}/${cyn}$0${hblk}]: ${cl}$toupper($1-)}
  //ctcp $0-}

### time thingy
on #-timer 69 * {
  if ([$mid(3 2 $Z)]==[00]) {
    deecho ${cyn}it is now ${hcyn}$Z${cl}}}

### names and sync stuff
alias names {
  if ([$0]) {
    @nameschannel=[$0]}
   {@nameschannel=[$C]}
  @ops=csort($chops($nameschannel))
  @lamers=csort($nochops($nameschannel))
  @delarray(oparray)
  @delarray(lamerarray)
  fe ($ops) op1 op2 op3 op4 op5 {  
    @tempstring=[]
    @opstring=[$op1 $op2 $op3 $op4 $op5]
    fe ($opstring) fixop {
      @push(tempstring $funk ${cyn}@$[9]fixop${hblk})}
    @setitem(oparray $numitems(oparray) $ccenter(66 ${hblk}$tempstring $funk))}
  fe ($lamers) l1 l2 l3 l4 l5 {
    @tempstring=[]
    @lamestring=[$l1 $l2 $l3 $l4 $l5]
    fe ($lamestring) fixlamer {
      @push(tempstring $funk ${hblu}$[10]checkvoice($fixlamer $nameschannel)${hblk})}
    @setitem(lamerarray $numitems(lamerarray) $ccenter(66 ${hblk}$tempstring $funk))}  
  if (numitems(oparray)) {
    echo $G ${hcyn}ÉÍÍÍÍÍÍÍÍÍÍÍ${cyn}ÍÍÍÍÄÄ${hblk}Ä $ccenter(28 ${hblu}operators on $nameschannel${hblk}: ${hwht}$#ops)
    for (@lx=0, lx < numitems(oparray), @lx++) {
      echo $G $namecolor($lx)º $getitem(oparray $lx)}}
  if (numitems(lamerarray)) {
    echo $G ${hcyn}ÉÍÍÍÍÍÍÍÍÍÍÍ${cyn}ÍÍÍÍÄÄ${hblk}Ä $ccenter(28 ${hblu}users on $nameschannel${hblk}: ${hwht}$#lamers)
    for (@lx=0, lx < numitems(lamerarray), @lx++) {
      echo $G $namecolor($lx)º $getitem(lamerarray $lx)}}
  if (!synching) {
    echo $G $namecolor(${lx + 1})ÈÍÍÍÍÍÍÍÍÍÍÄÄÄÄÄÄÄ  $ccenter(28 ${hblu}total on $nameschannel${hblk}: ${hwht}$numonchannel($nameschannel))}}
on ^channel_synch * {@schan=[$0];@synchtime=[$1]
  if ((!dccs)||(!dtog)) ^window set status_format3  %C%+%!
  @synching=[1];do names $schan
  @synching=[0]
  echo $G $namecolor(${lx + 1})ÈÍÍÍÍÍÍÄÄÄ      $ccenter(38 ${hblu}total on $schan${hblk}: ${hwht}$numonchannel($schan) ${hblk}- ${hblu}sync${hblk}: ${hwht}$fixfloattime($synchtime))}
     
### dynamic statusbar stuff
on -leave "*" {if ([$0]==[$N]) {if (!filter($1 $mychannels())) {^set status_format3  %> ;^window set status_format3  %> }}}
on ^timer "*" {do ^window set status_user8 $$fixuptime($uptime())}
on #-connect 44 * {_refresh_server}
on #-disconnect 44 * {_refresh_server}
alias _refresh_server {
  if (winnum()==1) {
    do ^set status_server $${hblk}\(${hcyn}server${hblk}:${cyn}$servah()${hblk}\)$${cl}}
  do ^window set status_server $${hblk}\(${hcyn}server${hblk}:${cyn}$servah()${hblk}\)$${cl}}
  
  
### server motd stuff
on ^001 "*" {deecho ${cyn}Welcome to the internet relay network${hblk}, ${hcyn}$7${hblk}.} 
on ^002 "*" {deecho ${cyn}You are connected to ${hcyn}$4${cyn} running ${hcyn}$7${hblk}.${cl}}
on ^003 "*" #
on ^004 "*" #
on ^250 "*" {deecho ${cyn}I have ${hcyn}$totcl${cyn} clients ${hblk}\(${hcyn}$4${cyn} max${hblk}\)${cyn} and ${hcyn}$totsr${cyn} server$plural($totsr) connected${hblk}.${cl}}
on ^251 "*" {deecho ${cyn}There are ${hcyn}${[$3] + [$6]}${cyn} users ${hblk}\(${hcyn}$3${hblk} + ${hcyn}$6${cyn} invisible${hblk}\)${cyn} on ${hcyn}$9${cyn} server$plural($9)${hblk}.${cl}} 
on ^252 "*" {deecho ${hcyn}$1${cyn} operators online}
on ^254 "*" {deecho ${hcyn}$1${cyn} channels have been formed}
on ^255 * {@totcl=[$3];@totsr=[$6]}
on ^265 "*" #
on ^266 "*" #

### dcc statusbar
on -dcc_transfer_stat "*" {
  do ^window set status_user3 $${hblk}\(${hcyn}sent${hblk}:${cyn}$fixsize($3)${hblk}/${hcyn}$sends${hblk} - ${hcyn}rcvd${hblk}:${cyn}$fixsize($0)${hblk}/${hcyn}$gets${hblk}\)${cl}}
on -dcc_statf "*" {
  @dcctype=[$1]
  @dccuser=[$2]}
on -dcc_statf1 "*" {
  @dccpercent=[$0]
  @dccbytes=[${[$2] - [$1]}]
  @dcceta=[$3\:$fixeta($4)]}
on -dcc_connect "*" {
  if (([$1]==[SEND])||([$1]==[GET])) {
    if ([$1]==[SEND]) {@sends=sends +1}
    if ([$1]==[GET]) {@gets=gets +1}
    @dccs=dccs + 1
    if (dtog) {
     do window set status_format2  %4 %>%L$broked_bx}
    ^hook getdccstats}}
on -dcc_lost "*" {
  if (([$1]==[SEND])||([$1]==[GET])) {
  @dccs=dccs - 1
  if ([$dccs]==[0]) {
    do window set status_format2  \${HBLK}\(%T%8${HBLK}\) %> %3 %L$broked_bx}
  ^timer 1 ^dcc stats}}
on ^hook getdccstats {
  if (([$dccs]!=[0])&&([$dtog])) {
      ^dcc
      if ([$dccpercent]!=[$lastdccpercent]) {
        @lastdccpercent=[$dccpercent]
        do ^window set status_user4 $${hblk}\(${hcyn}$dcctype${hblk}: ${cyn}$[9]dccuser ${hblk}[${cyn}$[5]fixsize($dccbytes) ${hcyn}ETA${hblk}:${cyn}$[-5]dcceta${hblk}]\) $${cl}[$$percentbar($dccpercent)$${hblk}]}
      ^timer 1 ^hook getdccstats}}
alias dtoggle {
  if ([$dtog]) {
    @dtog=[0]
    deecho dcc statusbar indicator toggled ${hblu}OFF${cl}
    if ([$dccs]) {
      do ^window set status_format2  \${HBLK}\(%T%8${HBLK}\) %> %3 %L$broked_bx}}
 {@dtog=[1]
  deecho dcc statusbar indicator toggled ${hblu}ON${cl}
  if ([$dccs]) {
    ^window set status_format2  %4 %>%L$broked_bx
    ^hook get dccstats}}}

### cdcc pack stuff
^on ^cdcc_prepack * if ([$0]==[$C]) {
     send $funk deep/cdcc:  /ctcp $N\ cdcc send #n #n2 #nx
     send $funk deep/cdcc:  slots open: $3/$4 $funk minspeed: $12kb/s}
    {notice $0 $funk deep/cdcc:  /ctcp $N\ cdcc send #n #n2 #nx
     notice $0 $funk deep/cdcc:  slots open: $3/$4 $funk minspeed: $12kb/s}
^on ^cdcc_pack * if ([$0]==[$C]) {
     send $funk #$[2]1 \($[5]fixsize($3) $[-3]4x\): $[40]5-}
    {notice $0 $funk #$[2]1 \($[5]fixsize($3) $[-3]4x\): $[40]5-}
^on ^cdcc_postpack * if ([$0]==[$C]) {
     send $funk      total grabbed: $fixsize($8) $funk record: $fixsize($7)/s}
    {notice $0 $funk      total grabbed: $fixsize($8) $funk record: $fixsize($7)/s}
^on -exit "*" {
  if ([$autocsave]==[on]) {cdcc save}
  deecho [time wasted: $newuptime()]}

### new mass command handler
alias mass {
  @pmass=[$0-];@mpattern=[*!*@*]
  if (rmatch($word(0 $pmass) o do v dv k b bk i)) {
    @mtype=word(0 $pmass)
    @pmass=notw(0 $pmass)
    if (([$[1]word(0 $pmass)]==[-])&&(word(0 $pmass)!=[-f])) {
      @mflag=strip(- $word(0 $pmass))
      @pmass=notw(0 $pmass)} {@mflag=[]} 
    if ([$mtype]==[o]) {@mflag=[l$strip(lo $mflag)]}
    if ([$mtype]==[do]) {@mflag=[o$strip(ol $mflag)]}
    if ([$mtype]==[v]) {@mflag=[q$strip(qv $mflag)]}
    if ([$mtype]==[dv]) {@mflag=[v$strip(vq $mflag)]}
    if ([$[1]word(0 $pmass)]==[#]) {
      @mchan=word(0 $pmass)
      @pmass=notw(0 $pmass)} {@mchan=[$C]}
    if ((word(0 $pmass)!=[-f])&&(word(0 $pmass))) {
      if (pattern(-f $pmass)) {
        @mpattern=beforew(-f $pmass)
        @pmass=fromw(-f $pmass)} {@mpattern=[$pmass]}}
    if ((word(0 $pmass)==[-f])&&(word(1 $pmass))) {
      @mfilter=restw(1 $pmass)} {@mfilter=[]}
    @chhosts=tmphosts=tmphosts2=[]
    fe ($onchannel($mchan)) mniq {
      @push(chhosts $mniq!$uhost($mniq))}
    fe ($mpattern) mpat {
      @tmphosts=pattern($mpat $chhosts)
      @push(tmphosts2 $tmphosts)}
    @chhosts=weed($tmphosts2)
    fe ($mfilter) phylt {
      @chhosts=filter($phylt $chhosts)}
    @mnicks=[]
    fe ($chhosts) chost {
      @push(mnicks $before(1 ! $chost))}
    fec ($mflag) phlag {
      switch ( $phlag ) {
        ( o ) {@mnicks=common($mnicks / $chops($mchan))}
        ( l ) {@mnicks=common($mnicks / $nochops($mchan))}
        ( v ) {@mnicks=common($mnicks / $chvoice($mchan))}
        ( q ) {@mnicks=common($mnicks / $chquiet($mchan))}
        ( u ) {@mnicks=common($mnicks / $chusers($mchan))}
        ( b ) {@mnicks=common($mnicks / $chbots($mchan))}
        ( s ) {@mnicks=common($mnicks / $chshits($mchan))}
        ( n ) {@mnicks=common($mnicks / $chnonusers($mchan))}}}
    @mnicks=filter($N $mnicks)
    if (mnicks) {
     deecho commencing mass-$mtype for $mchan on $#mnicks nick$plural($#mnicks)
     switch ( $mtype ) {
       ( o ) {do op $mchan $mnicks}
       ( do ) {do dop $mchan $mnicks}
       ( v ) {do voice $mchan $mnicks}
       ( dv ) {do unvoice $mchan $mnicks}
       ( k ) {@mknum=0;@mkreason=$defbootmsg
              fe ($mnicks) kickniq {
                do kick $mchan $kickniq [masskick/$mknum $getreason(1)]
                @mknum=mknum+1}}
       ( bk ) {@mknum=0;@mkreason=$defbootmsg
               fe ($mnicks) kickniq {
                 eval bk $mchan $kickniq [massbankick/$mknum $getreason(1)]
                 @mknum=mknum+1}}
       ( b ) {fe ($mnicks) banniq {
                do ban $mchan $banniq}}
       ( i ) {fe ($mnicks) inviteit {
                ^timer 1 do quote invite $inviteit $C}}}}
   {deecho no nicks found with the given arguments}}
   {dhelp mass}}
alias mk mass k $0-
alias lk mass k -l $0-
alias mknu mass k -n $0-
alias mko mass k -o $0-
alias mop mass o $0-
alias mdo mass do $0-
alias mvoice mass v $0-
alias mquiet mass dv $0-
alias mb mass dv $0-
alias mbk mass bk $0-

### fake msg relays
alias frelm {
  if ([$1]) {
    @fakemsg=[$1-]
    userhost $0 -cmd {
      if (([$3]!=[<UNKNOWN>])&&([$4]!=[<UNKNOWN>])) {
        send [$0] $fakemsg [$3@$4]}
       {deecho $0 is not on irc.}}}
   {dhelp frelm}}
alias freln {
  if ([$1]) {
    @fakemsg=[$1-]
    userhost $0 -cmd {
      if (([$3]!=[<UNKNOWN>])&&([$4]!=[<UNKNOWN])) {
        send \-$0\- $fakemsg}
       {deecho $0 is not on irc.}}}
   {dhelp freln}}

### new relay command
alias relay {
  @relflag=relnum=relnc=[]
  @prel=[$0-]
  @relkinds=[m sm c cr n sn i w sc d sd]
  @relcmds=[relm relsm relc relcr reln relsn reli relw relsc reld relsd]
  if (rmatch($word(0 $prel)) m sm c cr n sn i w sc d sd) {
    @reltype=copattern($word(0 $prel) relkinds relcmds)
    if (numitems($reltype)) {
    if (rmatch($word(1 $prel) -l -k -t)) {
      @relflag=word(1 $prel)
      @prel=notw(1 $prel)}
    if ([$isdigit($word(1 $prel))]==[0]) {
      @relnc=word(1 $prel)
      @prel=notw(1 $prel)}
    if ([$isdigit($word(1 $prel))]==[1]) {
      @relnum=numitems($reltype) - word(1 $prel)
      @relnum=relnum - 1}
     {@relnum=numitems($reltype) - 1}
    if ([$relflag]==[-t]) {
      if ([$[1]relnc]!=[#]) {
        @relnc=[$C]}
} 
    if ([$relflag]==[-k]) {
      if (([$[1]relnc]==[#])||(!relnc)) {
        @relnc=word(0 $getitem($reltype $relnum))}
      do boot $relnc $$cstrip($restw(1 $getitem($reltype $relnum)))}      
    if ([$relflag]==[-l]) {
      for (@pz=0, pz < numitems($reltype), @pz++) {
        @relnumz=numitems($reltype) - pz
        @relnumz=relnumz - 1
        deecho ${hwht}$pz ${hblk}$ccol ${cl}$restw(1 $getitem($reltype $relnumz))}}
    if (!relflag) {
      if (!relnc) {@relnc=[$C]}
      mysend $relnc $restw(1 $getitem($reltype $relnum))}} 
    {deecho the $reltype list is currently empty.}}      
   {dhelp relay}}
alias reld relay d $0-
alias relsd relay sd $0-
alias relsc relay sc $0-
alias relm relay m $0-
alias relsm relay sm $0-
alias relc relay c $0-
alias relcr relay cr $0-
alias reln relay n $0-
alias relsn relay sn $0-
alias reli relay i $0-
alias relw relay w $0- 
on ^hook "rel_add*" {
  if ([$numitems($1)]==[10]) {@delitem($1 0)}
  @setitem($1 $numitems($1) $2-)}

@scolors=[${BLU} ${BLK} ${RED} ${YEL} ${MAG} ${CYN} ${WHT} ${GRN} ${HBLU} ${HBLK} ${HRED} ${HYEL} ${HMAG} ${HCYN} ${HWHT} ${HGRN} ${BBLU} ${BBLK} ${BRED} ${BYEL} ${BMAG} ${BCYN} ${BWHT} ${BGRN} ${CL} ${CL1} ${BLNK}]
@foregrounds=[${BLK} ${WHT} ${RED} ${CYN} ${MAG} ${GRN} ${BLU} ${YEL} ${HBLK} ${HWHT} ${HRED} ${HCYN} ${HMAG} ${HGRN} ${HBLU} ${HYEL}]
@backgrounds=[${BBLK} ${BWHT} ${BRED} ${BCYN} ${BMAG} ${BGRN} ${BBLU} ${BYEL}]
@bluefade=[${HWHT} ${WHT} ${HCYN} ${HGRN} ${CYN} ${HBLU} ${BLU} ${HBLK}]
@redfade=[${HWHT} ${WHT} ${HMAG} ${HRED} ${MAG} ${RED} ${HBLK}]
@crazyfade=[$bluefade $redfade]
alias ranmirccols {
  @colorize=[$0-]
  @colorized=[]
  fec ($colorize) addcolor {
    @colorized=[$colorized$chr(3)$rand(15),$rand(8)$addcolor]}
  @function_return=[$colorized]}
alias rancols {
  @colorize=[$0-]
  @colorized=[]
  fec ($colorize) addcolor {
    @colorized=[$colorized$word($rand($#foregrounds) $foregrounds)]
    @colorized=[$colorized$word($rand($#backgrounds) $backgrounds)]
    @colorized=[$colorized$addcolor]}
  @function_return=[$colorized]}
alias bfade {
  @colorize=[$0-]
  @colorized=[]
  @blueindex=0
  fec ($colorize) addcolor {
    if (blueindex < #bluefade) {
      @colorized=[$colorized$word($blueindex $bluefade)$addcolor]
      @blueindex=blueindex +1}
     {@colorized=[$colorized$addcolor]}}
  @function_return=[$colorized]}
alias rfade {
  @colorize=[$0-]
  @colorized=[]
  @redindex=0
  fec ($colorize) addcolor {
    if (redindex < #redfade) {
      @colorized=[$colorized$word($redindex $redfade)$addcolor]
      @redindex=redindex +1}
     {@colorized=[$colorized$addcolor]}}
  @function_return=[$colorized]}
alias cfade {
  @colorize=[$0-]
  @colorized=[]
  @crazyindex=0
  fec ($colorize) addcolor {
    @colorized=[$colorized$word($crazyindex $crazyfade)$addcolor]
    @crazyindex=crazyindex + 1
    if (crazyindex > #crazyfade) {
      @crazyindex=0}}
  @function_return=[$colorized]}
alias lparse {
  if ([$0]==[c]) {@function_return=cfade($1-)}
  if ([$0]==[m]) {@function_return=rfade($1-)}
  if ([$0]==[b]) {@function_return=bfade($1-)}
  if ([$0]==[r]) {@function_return=rancols($1-)}
  if ([$0]==[mr]) {@function_return=ranmirccols($1-)}
  if ([$0]==[p]) {@function_return=cparse("$1-")}}
alias checkcolor {
  if (rmatch($0 c m b r mr p)) {@function_return=1} {@function_return=0}} 
alias msg {
  if ([$0]) {
    if (([$[1]1]==[-])&&(checkcolor($strip(- $1)))) {
      @lmsg=lparse($strip(- $1) $2-)}{
      @lmsg=[$1-]}
    //msg $0 $lmsg}}
alias say {
  if ([$0]) {
    if (([$[1]0]==[-])&&(checkcolor($strip(- $0)))) {
      @lsay=lparse($strip(- $0) $1-)}{
      @lsay=[$0-]}
    //say $lsay}}

### public message encryption
^on ^public "% % (!deep!)*" {
  @damsg=[$3-]
  @frum=[$0]
  do echo \${HBLK}\(${CL}$frum${HBLK}\) \${HGRN}\(encrypted\)\${CL} $$unfuckup($damsg)}  
^on ^public_other "% % (!deep!)*" {
  @damsg=[$3-]
  @frum=[$0]
  @chan=[$1]
  do echo $${HBLK}\(${CL}$frum${HBLK}/$${CL}$chan$${HBLK}\) $${HGRN}\(encrypted\)$${CL} $$unfuckup($damsg)}
alias crypt {
  if ([$0]) {
   send \(!deep!\) $fuckup($0-)}
  {dhelp crypt}}

### new message logger
on ^hook "dlog % *" {
  if ([$awaylog]==[on]) {
  @dlf=open($dlogfile W T)
  @write($dlf $mytime($Z)${BLU}$ccol${HBLK}[${CYN}$[8]toupper($center(8 $1))${HBLK}] ${CL}$2-)
  @close($dlf)
  @awaymesgs=awaymesgs +1}}
alias readlog {
  @readinglog=[1]
  more -r $dlogfile}
on ^hook "finishedlog" {
  if (readinglog) {
    input_char "erase this logfile? (y/n): " if ([$0]==[y]) {remlog}
    @readinglog=0}}
alias remlog {
  @awaymesgs=[0]
  @unlink($dlogfile)
  deecho logfile ${hblu}$dlogfile${cl} has been removed}

### setaway/setback and idlesetaway handler
alias gone away
alias away {
  @awaymsg=[]
  ^set msglog off
  if ([$0]==[-n]) {
    @awaylog=[off]
    @awaymsg=notw(0 $0-)} 
   {@awaylog=[on]
    @awaymsg=[$0-]}
  if (!awaymsg) {
    @awaymsg=[$defawaymsg]}
  @setawaytime=time()
  //^away $awaymsg
  echo ${hblk}$funk ${hwht}$N ${cl}is occupied: $awaymsg \(log:$awaylog\)
  ^hook dlog startlog message log started. on channels: $mychannels()
  @awaymesgs=awaymesgs - 1}
alias back {
  ^hook dlog closelog message log ended.
  @awaymesgs=awaymesgs - 1
  if ([$0]) {@backmsg=[$0-]} {@backmsg=[$defbackmsg]}
  @awaylog=[off]
  //back
  if (awaymesgs) {
    input_char "read awaylog now? (y/n): " if ([$0]==[y]) {readlog}}}
on -idle "*" {
  if (([$0]==[$idleawaytime])&&(!A)) {
    away $idleawaymsg}
  if (([$0]==[120])&&(A)&&(!pattern(*detached* $A))) {away $A [detached- email: $myemailaddy]}}
on #^timer 69 * {
  if (awaymsg) {
    do ^quote away :$A \(log:$awaylog\) [gone $nospace($tdiff2(${time() - setawaytime}))]}}

### simple reader for http grabber
alias http {
  more $ctoolz_dir/BitchX.http
  input_char "erase this http file? (y/N): " if ([$0]==[y]) {
    @unlink($ctoolz_dir/BitchX.http)
    deecho http file ${hblu}$ctoolz_dir/BitchX.http${cl} has been removed.}}

### ctcp handler
on ^ctcp "% % DCC SEND" #
on ^ctcp "% % CDCC SEND *" #
on ^ctcp "% % PAGE *" {
  if ([$[1]1]!=[#]) {
    deecho ${cyn}you have been paged by ${hcyn}$0 ${hblk}[${hblu}$userhost()${hblk}]  [${hwht}$3-${hblk}]   
    notice $0 Your request has been logged.}}
on ^ctcp "% % KEY *" {
  @chexored=checkuser($0!$strip(~ $userhost()) $3)
  if ((word(0 $chexored)>=20)&&([$4]==[$word(5 $chexored)])) {
    if (onchannel($3 $N)) {
      if (key($3)) {
        notice $0 Channel key for $3 is $key($3)}
       {notice $0 No key has been set for $3}}
     {notice $0 I'm not on $3}}
 {notice $0 Access denied.}}
 
### new kicks
alias boot {
  if ([$0]) {
  @bootnick=[$0]
  @bootchans=comchan($bootnick)
  if ([$1]) {@bootres=[$1-]} {@bootres=getreason($bootnick)}
  fe ($bootchans) curchan {
    if (ischanop($N $curchan)) {
        wait -CMD kick $curchan $bootnick $$bootres}}}
  {dhelp boot}}
alias dbk {
  if ([$0]) {@idiot=[$0]
    if ([$1]) {@idiotmsg=[$1-]} {@idiotmsg=getreason($idiot)}
    ban $C $idiot
    kick $C $idiot $idiotmsg
    timer 5 ub $C $idiot}
   {dhelp dbk}}
alias randkick {
  kick $C $word($rand($numonchannel($C)) $filter($N $onchannel($C))) -randomkick-}
on #-public 44 "*" if ([$repeatlimit]!=[0]) {
   if (([$2-]==[$repeatline])&&([$0]==[$repeatnk])&&(!ischanop($0 $1))) {
      @repeated=[${repeattime - time()}]
      if (([$repeated]<=[$repeatlimit])&&([$rkicker]==[on])) {
         //kick $1 $0 dont repeat repeat yourself}}
        {@repeatline=[$2-];@repeattime=[$time()];@repeatnk=[$0]}}
on -mode_stripped "*" {
  if (([$2]==[+b])&&(pattern($3 $N!$X))&&(ischanop($N $1))) {
    mode $1 -ob $0 $3
    kick $1 $0 don't ban $3 dickhead}}

### misc window hooks
on ^window "? % BitchX: *" deecho $3-
on ^window "? BitchX: *" deecho $2-
on ^window "? % *Auto-getting file % from %" #
on ^window "? % You have been marked as being*" #
on ^window "? % You are no longer marked as being*" #

@broked_bx=[ ]

### scan - fast names list
alias sc {scan $0-}
alias sco {scano $0-}
alias scn {scann $0-}
alias scv {scanv $0-}
alias scan {
  if ([$C]) {
    if ([$0]) {@scanc=[$0]} {@scanc=[$C]}
  @chpz=[];@nchpz=[]
  fe ($chops($scanc)) cho {@push(chpz @$cho)}
  fe ($nochops($scanc)) lame {
    if (isvoice($scanc $lame)) {@push(nchpz +$lame)} {@push(nchpz $lame)}}
  if (#chpz) {do echo \$G operators on \$scanc: $chpz}
  if (#nchpz) {do echo \$G non-operators on \$scanc: $nchpz}
  do echo \$G total users on \$scanc: $numonchannel($scanc)}}
alias scano {
  if ([$C]) {
    if ([$0]) {@scanoc=[$0]} {@scanoc=[$C]}
  if (chops($scanoc)) {
    @cheeze=[]
    fe ($chops($scanoc)) choad {@push(cheeze @$choad)}
    do echo \$G operators on \$scanoc: $cheeze}}}
alias scann {
  if ([$C]) {
    if ([$0]) {@scanoc=[$0]} {@scanoc=[$C]}
    if (nochops($scanoc)) {
      @cheeze=[]
      fe ($nochops($scanoc)) choad {@push(cheeze $choad)}
      do echo \$G non-operators on \$scanoc: $cheeze}}}
alias scanv {
  if ([$C]) {
    if ([$0]) {@scanoc=[$0]} {@scanoc=[$C]}
    if (chvoice($scanoc)) {
      @cheeze=[]
      fe ($chvoice($scanoc)) fuckface {@push(cheeze +$fuckface)}
      do echo \$G voiced users on \$scanoc: $cheeze}}}      

### 474 handler
on ^474 "*" {@bchan=[$1]
  deecho ${hblk}[${mag}$bchan${hblk}] ${cl}you are banned from this channel
  @delarray(banz)
  ^on ^367 "*" {
    if (pattern($2 $N!$X)) {
      @setitem(banz $numitems(banz) setby: ${hmag}$before(1 ! $3) ${hblk}/ ${mag}$2${cl})}
    ^on ^368 "*" {      
      ^on -367 "*" #
      ^on -368 "*" #}}
  do mode $bchan +b
  wait 
    if (numitems(banz)!=0) {
      deecho ${hblk}[${mag}$bchan${hblk}] ${cl}$numitems(banz) ban$plural($numitems(banz)) scanned:
      for (@xb=0, xb < numitems(banz), @xb++) {
        deecho ${hwht}${xb + 1} ${hblk}$ccol ${cl}$getitem(banz $xb)}}
     {^on -367 "*" #
      ^on -368 "*" #}}

### new email handler
on ^exec "from *" {
  deecho ${hblk}[${cyn}new email!${hblk}] ${hblu}from: ${cl}$safe($1-)}
on ^exec_error "from *" #
on ^mail "*" {
  ^timer 4 exec -name from frm | tail -1}
  
### nickname and prompt stuff
do ^on ^window '? $G % Regained nick %' {
  deecho $3-
  do nick $strip([] $5)}
alias nick {
  @niqq=[$0]
  if ([$niqq]==[-r]) {@niqq=randomnick()}
  if ([$niqq]==[-s]) {@niqq=scrollleft($N)}
  if ([$niqq]==[-f]) {@niqq=reverse($N)}
  do //nick $niqq
  wait 
  if ([$prtype]==[spin]) {@prtype=[norm]} {@prtype=[spin]} 
  prompt}
alias prompt {
  if ([$prtype]==[norm]) {@prtype=[spin];@nlen=strlen($N) * 2;@scrolltext= pad($nlen $N);@donscroll=[1];nickscroll}
  {@prtype=[norm];@donscroll=0;^timer 1 do ^set input_prompt $${HBLK}(${HBLU}$N${HBLK}) ${CL}}}
alias nickscroll {
  if ([$donscroll]==[1]) {
  @nscnt=nscnt + 1
  if ([$nscnt]==[$nlen]) {@nscnt=[0];if ([$ndir]==[1]) {@ndir=[0]} {@ndir=[1]}}
  if ([$ndir]==[1]) {@scrolltext=scrollleft($scrolltext)} {@scrolltext=scrollright($scrolltext)}
  do ^set input_prompt $${HBLK}(${HBLU}$left($strlen($N) $scrolltext)${HBLK}) $${CL}
  ^timer 1 nickscroll}}
alias scrollright {
  @slpt=strlen($0-) - 1
  @function_return=[$right(1 $0-)$left($slpt $0-)]}
alias scrollleft {
  @slpt=strlen($0-) -1
  @function_return=[$right($slpt $0-)$left(1 $0-)]}

### more - a file reader that uses the help pager
alias more {
  if ([$0]==[-r]) {@revflag=[r];@dlf=open($1 R)} {@revflag=[];@dlf=open($0 R)}
  @delarray(phyle)
  while (!eof($dlf)) {
    @setitem(phyle $numitems(phyle) $read($dlf))}
  @close($dlf)
  @unlink($deeppath/TEMPLOG)
  @fakefile=open($deeppath/TEMPLOG W)
  @phylesize=numitems(phyle) - 1
  if (!revflag) {
  for (@xz=0, xz < phylesize, @xz++) {
    @write($fakefile $getitem(phyle $xz))}}
 {for (@xz=phylesize, xz > -1, @xz--) {
    @write($fakefile $getitem(phyle $xz))}}
  @write($fakefile deep: end of logfile)
  @close($fakefile)
  ^on ^window "? *TEMPLOG*" #
  stack push set help_path
  stack push set help_window
  stack push set help_prompt
  ^set help_path $deeppath
  ^set help_window off
  ^set help_prompt off
  ^on ^window "? deep: end of logfile" {
    ^hook finishedlog
    ^on -window "? deep: end of logfile" #}
  //help TEMPLOG
  wait
  @unlink($deeppath/TEMPLOG)
  ^on -window "? *TEMPLOG*" #
  @delarray(phyle)
  stack pop set help_prompt
  stack pop set help_window
  stack pop set help_path}

### misc aliases nobody should be without
alias coffers {
  if ([$0]) {@chan=[$0]} {@chan=[$C]}
  @niqz=onchannel($chan)
  fe ($niqz) nigzor {if ([$nigzor]!=[$N]) {ctcp $nigzor xdcc list}}}
alias dcx dcc close chat $0
alias dcs dcc close send $0
alias dcg dcc close get $0
alias friend adduser $0 * 90 1 1
alias shit addshit $0 * 3 $1-
alias l leave 
alias leave {part $C}
alias mme {
  if (mychannels()) {
    fe ($mychannels()) mychan {
      if ([$mychan]==[$C]) {
        do me $0-}
       {do ^describe $mychan $0-}}}}
alias memo {
  if ([$0]) {
    @memfl=open($memofile W T)
    @write($memfl ${HBLK}[${HBLU}$strftime($time() %x @ %X)${HBLK}] ${CL}$0-)
    @close($memfl)
    deecho memo saved in ${HBLU}$memofile${cl}.}
   {if (fexist($memofile)==1) {
      deecho reading memos stored in ${HBLU}$memofile${cl}.
      more $memofile
      input "erase this memofile? (y/N): " if ([$0]==[y]) {@unlink($memofile)}}}}
alias opers {
  if ([$0]) {@serv=[$0]} {@serv=[$S]}
  @delarray(olinez)
  ^on ^243 "*" {
    @setitem(olinez $numitems(olinez) $4)}
  stats o $serv
  wait -cmd ^on -243 "*" #
  wait
  ^assign -operz
  for (@xz=0, xz < numitems(olinez), @xz++) {
    if (!match($getitem(olinez $xz) $operz)) {
      @push(operz $getitem(olinez $xz))}}
  if (operz) {
    deecho operators on $serv$ccol $operz}}
alias quit {
  if ([$0]) {//si $0-}
  {if ([$fsize(~/.BitchX/BitchX.quit)] > 0) {//si}
  {do //si wasted: $newuptime()}}}

### script configuration
alias setup {
  deecho ${hblu}current $deep configuration:
  deecho startup prompt type     ${hblk}[${cyn}$prtype${hblk}]${cl}
  deecho autosave cdcc on quit   ${hblk}[${cyn}$autocsave${hblk}]${cl}
  deecho repeat kick             ${hblk}[${cyn}$rkicker${hblk}]${cl}
  deecho default away message    ${hblk}[${cyn}$defawaymsg${hblk}]${cl}
  deecho default back message    ${hblk}[${cyn}$defbackmsg${hblk}]${cl}
  deecho your email address      ${hblk}[${cyn}$myemailaddy${hblk}]${cl}
  deecho functionkey 1           ${hblk}[${cyn}$fkey[1]${hblk}]${cl}
  deecho functionkey 2           ${hblk}[${cyn}$fkey[2]${hblk}]${cl}
  deecho functionkey 3           ${hblk}[${cyn}$fkey[3]${hblk}]${cl}
  deecho functionkey 4           ${hblk}[${cyn}$fkey[4]${hblk}]${cl}
  deecho functionkey 5           ${hblk}[${cyn}$fkey[5]${hblk}]${cl}
  deecho functionkey 6           ${hblk}[${cyn}$fkey[6]${hblk}]${cl}
  deecho functionkey 7           ${hblk}[${cyn}$fkey[7]${hblk}]${cl}
  deecho functionkey 8           ${hblk}[${cyn}$fkey[8]${hblk}]${cl}
  deecho press enter to keep the current value
  input_char "do you want to use the animated prompt? (y/N): " if ([$0]==[y]) {@prtype=[spin]} {if ([$0]!=[]) {@prtype=[norm]}} 
  input_char "do you want cdcc packs to autosave on quit? (y/N): " if ([$0]==[y]) {@autocsave=[on]} {if ([$0]!=[]) {@autocsave=[off]}}
  input_char "do you want repeat kick to be active? (y/N): " if ([$0]==[y]) {@rkicker=[on]} {if ([$0]!=[]) {@rkicker=[off]}}
  input "default away message: " if ([$0]!=[]) {@defawaymsg=[$0-]}
  input "default back message: " if ([$0]!=[]) {@defbackmsg=[$0-]}
  input "your email address: " if ([$0]!=[]) {@myemailaddy=[$0-]}
  input "functionkey 1: " if ([$0]!=[]) {@fkey[1]=[$0-]}
  input "functionkey 2: " if ([$0]!=[]) {@fkey[2]=[$0-]}
  input "functionkey 3: " if ([$0]!=[]) {@fkey[3]=[$0-]}
  input "functionkey 4: " if ([$0]!=[]) {@fkey[4]=[$0-]}
  input "functionkey 5: " if ([$0]!=[]) {@fkey[5]=[$0-]}
  input "functionkey 6: " if ([$0]!=[]) {@fkey[6]=[$0-]}
  input "functionkey 7: " if ([$0]!=[]) {@fkey[7]=[$0-]}
  input "functionkey 8: " if ([$0]!=[]) {@fkey[8]=[$0-]}
  input_char "save this configuration? (Y/n): " if ([$0]!=[n]) {
    statusecho $center(36 saving new configuration)
    @unlink($deepsave)
    @savefile=open($deepsave W T)
    @write($savefile statusecho  loaded $deep savefile created $strftime($time() %x) @ $fixtime($strftime($time() %X)))
    @write($savefile @prtype=[$prtype])
    @write($savefile @autocsave=[$autocsave])
    @write($savefile @rkicker=[$rkicker])
    @write($savefile @defawaymsg=[$defawaymsg])
    @write($savefile @defbackmsg=[$defbackmsg])
    @write($savefile @myemailaddy=[$myemailaddy])
    @write($savefile @fkey[1]=[$fkey[1]])
    @write($savefile @fkey[2]=[$fkey[2]])
    @write($savefile @fkey[3]=[$fkey[3]])
    @write($savefile @fkey[4]=[$fkey[4]])
    @write($savefile @fkey[5]=[$fkey[5]])
    @write($savefile @fkey[6]=[$fkey[6]])
    @write($savefile @fkey[7]=[$fkey[7]])
    @write($savefile @fkey[8]=[$fkey[8]])
    @close($savefile)}}

### echo stuff on the status bar
alias statusecho {
  @sexortemp=[$status_format1]
  do ^window set status_format1  $$0- 
  if (pattern($winnum() $windowshells)) {
    ^timer 5 do ^window set status_format1  %> $${hblk}\(${cyn}%T${hblk}\)   $${hblk}\(${hcyn}$windowshell${hblk}\)  $${hblk}\(${cyn}$X${hblk}\) $${cl}$broxed_bx}
   {^timer 5 ^window set status_format1 $sexortemp}}

### help alias
@readhelp=open($deephelp R)
while (!eof($readhelp)) {
  @helpline=[$read($readhelp)]
  if ([$[1]helpline]==[%]) {
    @helparrayname=[dhelp$after(1 % $helpline)]
    @delarray($helparrayname)}
   {if (([$word(0 $helpline)]!=[+])&&([$helpline]!=[])) {
      @setitem($helparrayname $numitems($helparrayname) ${hblk}[${cyn}usage${hblk}] ${cl}$helpline)}
     {@setitem($helparrayname $numitems($helparrayname) $helpline)}}}
@close($readhelp)

### country lookup table
@ domain[AD] = [Andorra]
@ domain[AE] = [United Arab Emirates]
@ domain[AF] = [Afghanistan]
@ domain[AG] = [Antigua and Barbuda]
@ domain[AI] = [Anguilla]
@ domain[AL] = [Albania]
@ domain[AM] = [Armenia]
@ domain[AN] = [Netherlands Antilles]
@ domain[AO] = [Angola]
@ domain[AQ] = [Antarctica]
@ domain[AR] = [Argentina]
@ domain[AS] = [American Samoa]
@ domain[AT] = [Austria]
@ domain[AU] = [Australia]
@ domain[AW] = [Aruba]
@ domain[AZ] = [Azerbaijan]
@ domain[BA] = [Bosnia and Herzegovina]
@ domain[BB] = [Barbados]
@ domain[BD] = [Bangladesh]
@ domain[BE] = [Belgium]
@ domain[BF] = [Burkina Faso]
@ domain[BG] = [Bulgaria]
@ domain[BH] = [Bahrain]
@ domain[BI] = [Burundi]
@ domain[BJ] = [Benin]
@ domain[BM] = [Bermuda]
@ domain[BN] = [Brunei Darussalam]
@ domain[BO] = [Bolivia]
@ domain[BR] = [Brazil]
@ domain[BS] = [Bahamas]
@ domain[BT] = [Bhutan]
@ domain[BV] = [Bouvet Island]
@ domain[BW] = [Botswana]
@ domain[BY] = [Belarus]
@ domain[BZ] = [Belize]
@ domain[CA] = [Canada]
@ domain[CC] = [Cocos (Keeling) Islands]
@ domain[CF] = [Central African Republic]
@ domain[CG] = [Congo]
@ domain[CH] = [Switzerland]
@ domain[CI] = [Cote D'Ivoire (Ivory Coast)]
@ domain[CK] = [Cook Islands]
@ domain[CL] = [Chile]
@ domain[CM] = [Cameroon]
@ domain[CN] = [China]
@ domain[CO] = [Colombia]
@ domain[CR] = [Costa Rica]
@ domain[CS] = [Czechoslovakia (former)]
@ domain[CU] = [Cuba]
@ domain[CV] = [Cape Verde]
@ domain[CX] = [Christmas Island]
@ domain[CY] = [Cyprus]
@ domain[CZ] = [Czech Republic]
@ domain[DE] = [Germany]
@ domain[DJ] = [Djibouti]
@ domain[DK] = [Denmark]
@ domain[DM] = [Dominica]
@ domain[DO] = [Dominican Republic]
@ domain[DZ] = [Algeria]
@ domain[EC] = [Ecuador]
@ domain[EE] = [Estonia]
@ domain[EG] = [Egypt]
@ domain[EH] = [Western Sahara]
@ domain[ER] = [Eritrea]
@ domain[ES] = [Spain]
@ domain[ET] = [Ethiopia]
@ domain[FI] = [Finland]
@ domain[FJ] = [Fiji]
@ domain[FK] = [Falkland Islands (Malvinas)]
@ domain[FM] = [Micronesia]
@ domain[FO] = [Faroe Islands]
@ domain[FR] = [France]
@ domain[FX] = [France, Metropolitan]
@ domain[GA] = [Gabon]
@ domain[GB] = [Great Britain (UK)]
@ domain[GD] = [Grenada]
@ domain[GE] = [Georgia]
@ domain[GF] = [French Guiana]
@ domain[GH] = [Ghana]
@ domain[GI] = [Gibraltar]
@ domain[GL] = [Greenland]
@ domain[GM] = [Gambia]
@ domain[GN] = [Guinea]
@ domain[GP] = [Guadeloupe]
@ domain[GQ] = [Equatorial Guinea]
@ domain[GR] = [Greece]
@ domain[GS] = [S. Georgia and S. Sandwich Isls.]
@ domain[GT] = [Guatemala]
@ domain[GU] = [Guam]
@ domain[GW] = [Guinea-Bissau]
@ domain[GY] = [Guyana]
@ domain[HK] = [Hong Kong]
@ domain[HM] = [Heard and McDonald Islands]
@ domain[HN] = [Honduras]
@ domain[HR] = [Croatia (Hrvatska)]
@ domain[HT] = [Haiti]
@ domain[HU] = [Hungary]
@ domain[ID] = [Indonesia]
@ domain[IE] = [Ireland]
@ domain[IL] = [Israel]
@ domain[IN] = [India]
@ domain[IO] = [British Indian Ocean Territory]
@ domain[IQ] = [Iraq]
@ domain[IR] = [Iran]
@ domain[IS] = [Iceland]
@ domain[IT] = [Italy]
@ domain[JM] = [Jamaica]
@ domain[JO] = [Jordan]
@ domain[JP] = [Japan]
@ domain[KE] = [Kenya]
@ domain[KG] = [Kyrgyzstan]
@ domain[KH] = [Cambodia]
@ domain[KI] = [Kiribati]
@ domain[KM] = [Comoros]
@ domain[KN] = [Saint Kitts and Nevis]
@ domain[KP] = [Korea (North)]
@ domain[KR] = [Korea (South)]
@ domain[KW] = [Kuwait]
@ domain[KY] = [Cayman Islands]
@ domain[KZ] = [Kazakhstan]
@ domain[LA] = [Laos]
@ domain[LB] = [Lebanon]
@ domain[LC] = [Saint Lucia]
@ domain[LI] = [Liechtenstein]
@ domain[LK] = [Sri Lanka]
@ domain[LR] = [Liberia]
@ domain[LS] = [Lesotho]
@ domain[LT] = [Lithuania]
@ domain[LU] = [Luxembourg]
@ domain[LV] = [Latvia]
@ domain[LY] = [Libya]
@ domain[MA] = [Morocco]
@ domain[MC] = [Monaco]
@ domain[MD] = [Moldova]
@ domain[MG] = [Madagascar]
@ domain[MH] = [Marshall Islands]
@ domain[MK] = [Macedonia]
@ domain[ML] = [Mali]
@ domain[MM] = [Myanmar]
@ domain[MN] = [Mongolia]
@ domain[MO] = [Macau]
@ domain[MP] = [Northern Mariana Islands]
@ domain[MQ] = [Martinique]
@ domain[MR] = [Mauritania]
@ domain[MS] = [Montserrat]
@ domain[MT] = [Malta]
@ domain[MU] = [Mauritius]
@ domain[MV] = [Maldives]
@ domain[MW] = [Malawi]
@ domain[MX] = [Mexico]
@ domain[MY] = [Malaysia]
@ domain[MZ] = [Mozambique]
@ domain[NA] = [Namibia]
@ domain[NC] = [New Caledonia]
@ domain[NE] = [Niger]
@ domain[NF] = [Norfolk Island]
@ domain[NG] = [Nigeria]
@ domain[NI] = [Nicaragua]
@ domain[NL] = [Netherlands]
@ domain[NO] = [Norway]
@ domain[NP] = [Nepal]
@ domain[NR] = [Nauru]
@ domain[NT] = [Neutral Zone]
@ domain[NU] = [Niue]
@ domain[NZ] = [New Zealand (Aotearoa)]
@ domain[OM] = [Oman]
@ domain[PA] = [Panama]
@ domain[PE] = [Peru]
@ domain[PF] = [French Polynesia]
@ domain[PG] = [Papua New Guinea]
@ domain[PH] = [Philippines]
@ domain[PK] = [Pakistan]
@ domain[PL] = [Poland]
@ domain[PM] = [St. Pierre and Miquelon]
@ domain[PN] = [Pitcairn]
@ domain[PR] = [Puerto Rico]
@ domain[PT] = [Portugal]
@ domain[PW] = [Palau]
@ domain[PY] = [Paraguay]
@ domain[QA] = [Qatar]
@ domain[RE] = [Reunion]
@ domain[RO] = [Romania]
@ domain[RU] = [Russian Federation]
@ domain[RW] = [Rwanda]
@ domain[SA] = [Saudi Arabia]
@ domain[Sb] = [Solomon Islands]
@ domain[SC] = [Seychelles]
@ domain[SD] = [Sudan]
@ domain[SE] = [Sweden]
@ domain[SG] = [Singapore]
@ domain[SH] = [St. Helena]
@ domain[SI] = [Slovenia]
@ domain[SJ] = [Svalbard and Jan Mayen Islands]
@ domain[SK] = [Slovak Republic]
@ domain[SL] = [Sierra Leone]
@ domain[SM] = [San Marino]
@ domain[SN] = [Senegal]
@ domain[SO] = [Somalia]
@ domain[SR] = [Suriname]
@ domain[ST] = [Sao Tome and Principe]
@ domain[SU] = [USSR (former)]
@ domain[SV] = [El Salvador]
@ domain[SY] = [Syria]
@ domain[SZ] = [Swaziland]
@ domain[TC] = [Turks and Caicos Islands]
@ domain[TD] = [Chad]
@ domain[TF] = [French Southern Territories]
@ domain[TG] = [Togo]
@ domain[TH] = [Thailand]
@ domain[TJ] = [Tajikistan]
@ domain[TK] = [Tokelau]
@ domain[TM] = [Turkmenistan]
@ domain[TN] = [Tunisia]
@ domain[TO] = [Tonga]
@ domain[TP] = [East Timor]
@ domain[TR] = [Turkey]
@ domain[TT] = [Trinidad and Tobago]
@ domain[TV] = [Tuvalu]
@ domain[TW] = [Taiwan]
@ domain[TZ] = [Tanzania]
@ domain[UA] = [Ukraine]
@ domain[UG] = [Uganda]
@ domain[UK] = [United Kingdom]
@ domain[UM] = [US Minor Outlying Islands]
@ domain[US] = [United States]
@ domain[UY] = [Uruguay]
@ domain[UZ] = [Uzbekistan]
@ domain[VA] = [Vatican City State (Holy See)]
@ domain[VC] = [Saint Vincent and the Grenadines]
@ domain[VE] = [Venezuela]
@ domain[VG] = [Virgin Islands (British)]
@ domain[VI] = [Virgin Islands (U.S.)]
@ domain[VN] = [Viet Nam]
@ domain[VU] = [Vanuatu]
@ domain[WF] = [Wallis and Futuna Islands]
@ domain[WS] = [Samoa]
@ domain[YE] = [Yemen]
@ domain[YT] = [Mayotte]
@ domain[YU] = [Yugoslavia]
@ domain[ZA] = [South Africa]
@ domain[ZM] = [Zambia]
@ domain[ZR] = [Zaire]
@ domain[ZW] = [Zimbabwe]
@ domain[COM] = [Commercial]
@ domain[EDU] = [Educational]
@ domain[GOV] = [Government]
@ domain[INT] = [International]
@ domain[MIL] = [Military]
@ domain[NET] = [Network]
@ domain[ORG] = [Non-Profit Organization]
@ domain[RPA] = [Old style Arpanet]
@ domain[ATO] = [Nato field]

### formats
set format_dcc_connect $G %K[ %K$funk %c$2 %K$funk %Cdcc connect%K/%c$1 %K]: (%n$4, port $5%K)%n
set format_dcc_lost $G %K[ %K$funk %C$5 %K$funk %cdcc complete%K/%C$1 %K]: (%n$6 sec$plural($6), $3 : $7$8/sec%K)%n
set format_dcc_request $G %K[ %K$funk %b$3 %K$funk %Bdcc request%K/%b$1 %K]: (%n$2/$8$7 : $5, port $6%K)%n
set format_dcc_error $G %K[ %K$funk %B$2 %K$funk %bdcc lost%K/%B$1 %K]: (%n$3-%K)%n
set format_public %K(%n$1%K)%n $mircansi($3-)
set format_public_ar %K(%G$1%K)%n $mircansi($3-)
set format_public_other %K(%n$1%K/%n$2%K)%n $mircansi($3-)
set format_public_other_ar %K(%G$1%K/%G$2%K)%n $mircansi($3-)
set format_send_public %K(%B$2%K)%n $mircansi($3-)
set format_send_public_other %K(%B$2%K/%n$1%K)%n $mircansi($3-)
set format_userlist_header %KÚÄÄ%Bnick!user@host%KÄÄÄÄÄÄÄÄÄÄÂ%Baop%KÂ%Bprt%KÂ%Blev%KÂÄ%Bpassword%KÄÂÄÄ%Bchannels%KÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿%n
set format_userlist %K³%W$[26]fuxit($3 $5)%K³%W$[-3]2%K³%W$[-3]1%K³%W$[-3]0%K³%W$[10]center(10 $4)%K³%W$[25]6-%K³%n
set format_userlist_footer %KÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ%n
set format_bot_header %KÚÄÄ%Gbotnick!user@host%KÄÄÄÄÄÄÄÄÄÄÄÂ%Gaop%KÂ%Gprt%KÂÄÄ%Gchannels%KÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿%n
set format_bot %K³%W$[30]fuxit($2 $4)%K³%W$[-3]0%K³%W$[-3]1%K³%W$[36]3%K³%n
set format_bot_footer %KÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ%n
set format_shitlist_header %KÚÄÄ%Rnick@user@host%KÄÄÄÄÄÄÄÄÄÄÂ%Rlev%KÂÄÄ%Rchannels%KÄÄÄÄÂÄÄ%Rreason%KÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿%n
set format_shitlist %K³%W$[26]1%K³%W$[-3]0%K³%W$[14]center(14 $2)%K³%W$[29]3-%K³%n
set format_shitlist_footer %KÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ%n
set format_473 $G %K[%m$1%K] %nis invitation only
set format_475 $G %K[%m$1%K] %ninvalid channel key
set format_476 $G %K[%m$1%K] %nyou are not a channel operator
set format_netadd $G new server %B$1$%n added to $2
set format_netsplit $G %K[%Cnetsplit%K] %B$1%n split from $2
set format_netjoin $G %K[%Cnetjoined%K] %B$1%n joined to $2
set format_wall %K[%G!%g$1%K:$2%G!%K] %n$mircansi($3-)
set format_send_away [ setaway since $strftime($1 %a, %b %d @ %I:%M)$tolower($strftime($1 %p))  (log:$awaylog) ]
set format_status3 $0-
set format_status2 $0-
set format_status1 $0-
set format_status $0-
set format_whois_header %CÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ%cÍÍÍÍÄÄÄÄÄÄÄÄÄÄÄÄÄÄ%KÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
set format_whois_nick %Cº  %W$0%K [%n$1%K@%n$fixhost($2)%K]%n $country($2) $noident($1)
set format_whois_name %Cº  %Cn%ca%Kme       %Kú%n $0-
set format_whois_server %cº  %Cse%crv%Ker     %Kú%n $0 %K(%n$1-%K)%n
set format_whois_channels %cº  %Ccha%cnne%Kls   %Kú%n $0-
set format_whois_friend %cº  %Cfr%cie%Knd     %Kú%n %Wl%K/%n$0 %Wa%K/%n$1 %Wp%K/%n$2
set format_whois_bot %cº  %Cb%co%Kt        %Kú%n %Wa%K/%n$0 %Wp%K/%n$1
set format_whois_shit %cº  %Cshi%ctli%Ksted %Kú%n %Wl%K/%n$0 %K(%n$1%K)%n $2-
set format_whois_away %Kº  %Ca%cw%Kay       %Kú%n $1-
set format_whois_idle %Kº  %Ci%cd%Kle       %Kú%n $fixihr($0)$fiximn($1)$fixisc($2)
set format_whois_oper %Kº  %Cop%cer%Kator   %Kú%n dug in muh anal cave
set format_whois_footer %KÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
set format_whowas_header %CÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ%cÍÍÍÍÄÄÄÄÄÄÄÄÄÄÄÄÄÄ%KÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
set format_whowas_nick %Cº  %W$0%K [%n$1%K@%n$fixhost($2)%K]%n
set format_whowas_footer %KÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
set format_send_ctcp $fsend %K[%Cctcp%K/%c$1%K]:%n $2-
set format_send_msg $fsend %K[%Cmsg%K/%c$1%K]:%n $mircansi($3-)%n
set format_send_dcc_chat $fsend %K[=%p$1%K=]:%n $mircansi($2-)%n
set format_invite_user $fsend %K[%Cinvite%K/%c$2-%K]:%n $1
set format_invite $G %K[ $funk %c$1 %K$funk %Cinvite%K/%c$2-%K]:%n
set format_nick_comp $0:$1-
set format_nick_auto $0:$1-
set format_version $tolower($0)$deep - $2 $3
set format_away is occupied: $3- (log:$awaylog) 
set format_back has returned: $backmsg [gone $nospace($tdiff2(${time() - setawaytime}))]
set format_dcc_chat %K[%C$1%K(%cdcc%K)] %n$mircansi($3-)
set format_msg %K[%c$1%K]%n $mircansi($3-)%n %K[%c$2%K]%n
set format_notice %K-%B$1%K-%n $mircansi($3-)%n
set format_join $G %K[ $funk %c$1 %K$funk %Cjoin%K/%c$3%K ]: (%n$fixip($2)%K)%n
set format_friend_join $G %K[ $funk %c$1 $ %K(%n$botorfriend($1!$fixip($2) $3)%K) $funk %Cjoin%K/%c$3%K ]: (%n$fixip($2)%K)%n
set format_leave $G %K[ $funk %b$1 %K$funk %Bpart%K/%b$3%K ]: (%n$fixip($2)%K)%n
set format_channel_signoff $G %K[ $funk %r$1 %K$funk %Rsignoff%K/%r$3 %K]: (%n$mircansi($4-)%K)%n
set format_mode $G %K[ $funk %m$1 %K$funk %Mmode%K/%m$3%K ]: (%n$4-%K)%n
set format_mode_channel $G %K[ $funk %m$1 %K$funk %Mmode%K/%m$3%K ]: (%n$4-%K)%n
set format_smode $G %K[ $funk %m$1 %K$funk %Mservermode%K/%m$3%K ]: (%n$4-%K)%n
set format_usermode $G %K[ $funk %Musermode%K/%m$3%K ]: (%n$4-%K)%n
set format_nickname $G %K[ $funk %c$1 %K$funk %Cnickchange ]: %n$3
set format_nickname_other $G %K[ $funk %c$1 %K$funk %Cnickchange ]: %n$3
set format_notify_signon_uh $fsend signon%K:%n $1 %K(%n$2%K@%n$3%K)%n
set format_notify_signoff_uh $fsend signoff%K:%n $1 %K(%n$2%K@%n$3%K)%n
set format_ctcp $G %K[ $funk %g$1 %K$funk %Gctcp $fixctcp($4-) request%K/%g$fixcnick($3)%K ]: (%n$2%K)%n
set format_ctcp_reply $G %K[ $funk %G$1 %K$funk %gctcp reply%K/%G$3%K ]: (%n$4-%K)%n
set format_ctcp_cloak $G %K[ $funk %g$1 %K$funk %Gctcp $fixctcp($4-) request%K/%g$fixcnick($3)%K ]: (%n$2%K)%n
set format_ctcp_cloak_func $G %K[ $funk %g$1 %K$funk %Gctcp $fixctcp($4-) request%K/%g$fixcnick($3)%K ]: (%n$2%K)%n
set format_ctcp_cloak_func_user $G %K[ $funk %g$1 %K$funk %Gctcp $fixctcp($4-) request%K/%g$fixcnick($3)%K ]: (%n$2%K)%n
set format_ctcp_cloak_unknown $G %K[ $funk %g$1 %K$funk %Gunknown ctcp $fixctcp($4-) request%K/%g$fixcnick($3)%K ]: (%n$2%K)%n
set format_ctcp_cloak_unknown_user $G %K[ $funk %g$1 %K$funk %Gunknown ctcp $fixctcp($4-) request%K/%g$fixcnick($3)%K ]: (%n$2%K)%n
set format_ctcp_cloak_user $G %K[ $funk %g$1 %K$funk %Gctcp $fixctcp($4-) request%K/%g$fixcnick($3)%K ]: (%n$2%K)%n
set format_ctcp_func $G %K[ $funk %g$1 %K$funk %Gctcp $fixctcp($4-) request%K/%g$fixcnick($3)%K ]: (%n$2%K)%n
set format_ctcp_func_user $G %K[ $funk %g$1 %K$funk %Gctcp $fixctcp($4-) request%K/%g$fixcnick($3)%K ]: (%n$2%K)%n
set format_ctcp_unknown $G %K[ $funk %g$1 %K$funk %Gunknown ctcp $fixctcp($4-) request%K/%g$fixcnick($3)%K ]: (%n$2%K)%n
set format_ctcp_unknown_user $G %K[ $funk %g$1 %K$funk %Gunknown ctcp $fixctcp($4-)request%K/%g$fixcnick($3)%K ]: (%n$2%K)%n
set format_ctcp_user $G %K[ $funk %g$1 %K$funk %Gctcp $fixctcp($4-) request%K/%g$fixcnick($3)%K ]: (%n$2%K)%n
set -format_nickname_user
set -format_notify_signon
set -format_notify_signoff
set -format_nickname_user
set -format_notify_signon
set -format_notify_signoff
set -format_send_notice

### ending routines
clear -all
if (!sends) {@sends=[0]}
if (!gets) {@gets=[0]}
^dcc stats
do set client_information $clinfo
do set status_format1  ${HBLK}\(%*%=%@${hwht}%N%#%A${HBLK}\) %> %M %Q %S 
do set status_format2  ${HBLK}\(%T%8${HBLK}\) %> %3 %L 
do window set status_format1  ${HBLK}\(%*%=%@${hwht}%N%#%A${HBLK}\) %> %M %Q %S 
do window set status_format2  ${HBLK}\(%T%8${HBLK}\) %> %3 %L 
set status_format3  %> 
set double 2
window double on
window split on
if (fexist($deepsave)!=1) {
  deecho thanks for choosing $deep as your script.  any questions, comments,
  deecho bugs, complaints, or suggestions can be sent to me, shade on the efnet,
  deecho or email sk@dhp.com.
  input_char "would you like to configure now? (y/N): " if ([$0]==[y]) {setup}}
 {do load $deepsave}
if (mychannels()) {^window set status_format3  %C%+%! } {^window set status_format3  %> }
if ([$prtype]==[spin]) {@prtype=[norm];prompt} {@prtype=[spin];prompt}
do deecho $deepver now loaded. try /dhelp for help!
@idleawaymsg=[idle $idleawaytime minute$plural($idleawaytime)]
### END OF PHYLE. DIE. 
