#^assign format_set_header %W ÚÄ%nÄ%WÄÄ%nÄÄÄ%cÄ%nÄÄ%c- Ä- -  - %K-     -%n
#^assign format_set_footer %c ÀÄÄ-- -   -%K-  -    -%n

alias users lusers

on ^001 * #
on ^002 * #
on ^003 * #
on ^004 * {
  @ _lu.v = [$2]}
on ^251 * {
  echo $box.head()
  echo $box.echo_head($(c.lc)statistics for $S ${_lu.v ? [$(c.lm)\($(cl)$_lu.v$(c.lm)\)$(cl)..] :})
  ^on ^raw_irc "$S % $N :Highest connection count*" {
    @ _lu.lum = _lu.um = []
    ^shook 266 0 0 0 0 0 0 0}
  @ _lu.u = [$3] + [$6]
  @ _lu.i = [$6]
  @ _lu.s = [$9]}
on ^252 * {
  @ _lu.o = [$1]}
on ^254 * {
  @ _lu.c = [$1]}
on ^255 * {
  @ _lu.lu = [$3]
  @ _lu.ls = [$6]}
on ^265 * {
  @ _lu.lum = [$6]}
on ^266 * {
  ^on ^raw_irc -"$S % $N :Highest connection count*" #
  @ _lu.um = [$6]
  ^tempset floating_point_math_var on
  echo $box.echo($(cl)global users$(c.hk).. $(cl)$numdots(8 $_lu.u) ${_lu.um?[$(cl)max$(c.hk).. $(cl)$numdots(8 $_lu.um) ]:}$(c.lm)\($(cl)$_lu.i invisible, $_lu.o operators$(c.lm)\))
  echo $box.echo($(cl)local users$(c.hk)... $(cl)$numdots(8 $_lu.lu) ${_lu.lum?[$(cl)max$(c.hk).. $(cl)$numdots(8 $_lu.lum) ]:}$(c.lm)\($(cl)$trunc(1 ${100 * _lu.lu / _lu.u})\%$(c.lm)\))
  echo $box.echo($(cl)servers$(c.hk)....... $(cl)$numdots(8 $_lu.s) $(c.lm)\($(cl)$trunc(1 ${_lu.u / _lu.s}) avg users per server$(c.lm)\))
  echo $box.echo($(cl)channels$(c.hk)...... $(cl)$numdots(8 $_lu.c) $(c.lm)\($(cl)$trunc(1 ${_lu.u / _lu.c}) avg users per channel$(c.lm)\))
  echo $box.footer()
  ^untset floating_point_math_var}

^set format_wholeft_header $box.head()
^set format_wholeft_footer $box.footer()
^set format_wholeft_user $box.echo($cparse("$[-10]0%K!%n$numdots(20 $1) %K[%c$numdots(12 $2)%K]%n $strip($$ $[20]4) %K[%c$3s%K]%n"))

alias s if ([$0]) {
  m $0 ${[$1] ? [xdcc send #$1] : [xdcc list]}}

alias v voice
alias dv devoice

^set format_set $G $numdots(30 $tolower($0))%n $1-
^set format_set_novalue $G $numdots(30 $tolower($0))%n %m(%nempty%m)%n

^set format_action_other %Kð %W$1%n/%c$3%n $4-

alias tempset {
  ^stack push set $0
  ^set $0 $1-}

alias untset {
  ^stack pop set $0}

^on ^action * {
  if ([$1] == N) {
    echo $fparse(format_action_user $tolower($Z) $0 $userhost() $2-)} elsif (tolower($winchan($chanwin($1))) != tolower($1)) {
    echo $fparse(format_action_other $tolower($Z) $0 $userhost() $1 $2-)} else {
    echo $fparse(format_action $tolower($Z) $0 $userhost() $1 $2-)}}

^on ^send_action * {
  if ([$0] == C) {
    echo $fparse(format_send_action $tolower($Z) $N $0 $1-)} else {
    echo $fparse(format_send_action_other $tolower($Z) $N $0 $1-)}}

@ format_echo_away = [$$G %K\[%caway%m/%n$$0%K\]%n $$1-]

^on ^hook "away *" {
  unless (match($1 $anicks)) {
    @ push(anicks $1)
    echo $cparse("$format_echo_away" $1 $2-)
    expire 60 anicks $1}}

^on ^301 * {
  if (ws.nick) {
    @ ws.away = [$1-]} else {
    ^hook away $0 $1-}}

^on ^311 * {
  ^purge ws
  @ ws.yes = 1
  @ ws.nick = [$1]
  @ ws.user = [$2]
  @ ws.host = [$3]
  @ ws.name = [$5-]}

^on ^313 * {
  @ ws.oper = 1}

^on ^319 * {
  @ push(ws.chan $1-)}

^on ^312 * {
  @ ws.serv = [$1]
  @ ws.sres = [$2] =~ [\[*\]] ? [$3-] : [$2-]}

^on ^317 * {
  @ ws.ih = ws.im = ws.is = [0]
  @ ws.ih = pattern(*h $tdiff2($2)) ? (before(h $pattern(*h $tdiff2($2))) + (pattern(*d $tdiff2($2)) ? (24 * before(d $pattern(*d $tdiff2($2)))) : 0)) : [0]
  @ ws.im = pattern(*m $tdiff2($2)) ? before(m $pattern(*m $tdiff2($2))) : [0]
  @ ws.is = pattern(*s $tdiff2($2)) ? before(s $pattern(*s $tdiff2($2))) : [0]}

^set format_whois_nick %G| %W$0 %K(%n$1@$2%K) $3-
^set format_whois_idle %K: %Wi%ndle     : $0 hours $1 mins $2 secs

^on ^set "whois_continue *" {
  ^assign whois_continue $1-}

^on ^set "whois_country *" {
  ${[$1-]?[^assign whois_country $1-]:[^assign -whois_country]}}

^on ^318 * {
  if (ws.yes) {
    ^set continued_line $cparse("$whois_continue")
    echo $fparse(format_whois_header)
    echo $fparse(format_whois_nick $ws.nick $ws.user $ws.host ${country($after(-1 . $ws.host)) != [unknown] ? cparse("$whois_country" $tolower($remw(\(pHEAR\) $country($after(-1 . $ws.host))))) :}${flag(ws.oper) ? [ $(c.hk)\($(c.hw)i$(cl)rc$(c.hk)/$(cl)op$(c.hk)\)$(cl)] :})
    echo $fparse(format_whois_name $ws.name)
    ^local aa $listed($ws.nick!$ws.user@$ws.host)
    if (aa) {echo $fparse(format_whois_$aa)}
    if (ws.chan) {echo $fparse(format_whois_channels $ws.chan)}
    echo $fparse(format_whois_server $ws.serv $ws.sres)
    if (ws.away) {echo $fparse(format_whois_away $ws.nick $ws.away)}
    if (ws.is||ws.im||ws.ih) {echo $fparse(format_whois_idle $ws.ih $ws.im $ws.is)}
    if (format_whois_footer) {echo $fparse(format_whois_footer)}
    @ ws.yes = 0
    ^set continued_line $repeat(4  )}}
on -set "format_whois_header *" {
  ^fset format_whowas_header $1-}
on -set "format_whois_nick *" {
  ^fset format_whowas_nick $1-}
on ^369 * {
  echo $cparse("$format_whois_footer")}
on -set "format_join *" {
  ^fset format_friend_join $1- %K\(%nfriend%K\)%n}
on -set "format_mode *" {
  ^fset format_smode $1-}
alias relwi {
  if (ws.nick) {
    ^local bb ${[$0]?[$0]:C}
    msg $bb $_fparse(format_whois_header)
    msg $bb $_fparse(format_whois_nick $ws.nick $ws.user $ws.host ${country($after(-1 . $ws.host)) != [unknown] ? cparse("$whois_country" $tolower($remw(\(pHEAR\) $country($after(-1 . $ws.host))))) :}${flag(ws.oper) ? [ $(c.hk)\($(c.hw)i$(cl)rc$(c.hk)/$(cl)op$(c.hk)\)$(cl)] :})
    msg $bb $_fparse(format_whois_name $ws.name)
    ^local aa $listed($ws.nick!$ws.user@$ws.host)
    if (aa) {msg $bb $_fparse(format_whois_$aa)}
    if (ws.chan) {msg $bb $_fparse(format_whois_channels $ws.chan)}
    msg $bb $_fparse(format_whois_server $ws.serv $ws.sres)
    if (ws.away) {msg $bb $_fparse(format_whois_away $ws.nick $ws.away)}
    if (ws.is||ws.im||ws.ih) {msg $bb $_fparse(format_whois_idle $ws.ih $ws.im $ws.is)}
    if (format_whois_footer) {msg $bb $_fparse(format_whois_footer)}} else {
    ge the whois buffer is empty.}}

on ^mail * {
	@_aa=pipe(frm|tail -1)
	if (_aa) {
		ge $(c.lc)new email!$(cl)  from$(c.hk): $(cl) $_aa
		@_aa=[]} else {
		ge you have $(c.lc)new email$(cl).}}

on -timer * {
  fe ($mychannels()) aa {
    if (numonchannel($aa) == 1 &! ischanop($N $aa) && flag(a.recycle)) {
      ge cycling $aa to regain ops...
      cycle $aa}}
  if (Z =~ [??:00??]) {
    ge it is now $(c.lc)$Z$(cl).}}

alias frelm {
  if ([$1]) {
    ^local aa $_userhost($0)
    if (aa) {
      say $_fparse(format_msg ! $0 $aa $1-)} else {
      ge $0 is not on irc.}} else {
    ausage frelm}}
alias freln {
  if ([$1]) {
    ^local aa $_userhost($0)
    if (aa) {
      say $_fparse(format_notice ! $0 $aa $1-)} else {
      ge $0 is not on irc.}} else {
    ausage freln}}
alias rctcp {
  if ([$1]) {
    ^quote NOTICE $0 :$toupper($1) $2-
    ge faked CTCP $toupper($1)\: $2- sent to $0} else {
    ausage rctcp}}
alias 4v {
  if ([$*]) {
    ^local niq ${_ischannel($0)?[$1]:[$0]}
    mode ${_ischannel($0)?[$0]:C} +vvvv $niq $niq $niq $niq} else {
    ausage 4v}}
alias unflash {
  clear -all -unhold
  exec reset
  reset
  parsekey refresh_screen}
alias coffers {
	fe ($filter($N $onchannel(${[$0]?[$0]:C}))) aa {
		^ctcp $aa xdcc list}}
alias friend {
	${[$0]?[adduser -ppp $0 ${[$1]?[$1]:[*]} friend]:[ausage friend]}}
alias shit {
	${[$0]?[addshit ${[$0]=~[*@*]?[$0]:[$0!$maskhost($_userhost($0))]} * 3 ${[$1]?[$strftime($time() %x)\: $1-]:[$strftime($time() %x)\: shitlisted.]}]:[ausage shit]}}
alias memo {
	if ([$*] && ([$*] !~ [-r*])) {
		@memfl=open($a.memofile W)
		@write($memfl $datetime($time()) $(cl)$*)
		@close($memfl)
		ge memo saved in $a.memofile\.} else {
		switch ($*) {
                  (-r*) {@unlink($a.memofile)
                         ge removed memofile.}
                  (*) {if (fexist($a.memofile)==1) {
			more $a.memofile} else {
			ge the memo file is empty.}}}}}
alias opers trace -o $*

alias lj if (match($0 k -k kb -kb o -o v -v)) {
  if (getitem(lj.$C 0)) {
    switch ($0) {
      (k) (-k) {
        kick $C $getitem(lj.$C 0) ${[$1-]?[$1-]:getreason($getitem(lj.$C 0))}}
      (kb) (-kb) (bk) (-bk) {
        kb $getitem(lj.$C 0) ${[$1-]?[$1-]:getreason($getitem(lj.$C 0))}}
      (o) (-o) {
        mode $C +o $getitem(lj.$C 0)}
      (v) (-v) {
        mode $C +v $getitem(lj.$C 0)}}} else {
    ge no joins to channel yet. $(c.lm)\($(cl)$C$(c.lm)\)$(cl)}} else {
  if (getitem(lj.$C 0)) {
    ge last join to $(c.lm)\($(cl)$C$(c.lm)\)$(c.hk):$(cl) $getitem(lj.$C 0)}
    ausage lj}

alias license {
  more ~/argon/LICENSE}

alias cycle {
  ^local aa ${ischannel($0) ? [$0] : C}
  if (chanmode($aa) =~ [*i*] && numonchannel($aa) > 1) {
    ge can't cycle, $aa is +i.} else {
    //cycle $aa}}
#psy/sjk'97
