^set nick_completion off

^on ^set "channel_synch *" {
  @ channel_synch = [$1-]}

^on ^channel_synch * {
  echo $cparse("$channel_synch" $0 $_fixstime($1))}

^on ^input '%: *' {
  ^local nco.
  @ nco.p = before(: $0)
  @ nco.c = _compnick($nco.p)
  if (leftw(1 $nco.c) && C == T) {
    sendline $stripansicodes($fparse(format_nick_comp $restw(1 $nco.c)  $1-))
    addtab $rightw(${#nco.c - 1} $nco.c):} else {
    sendline $*}}

^on #-332 1 * {
  @ setitem(topic.$1 0 $2-)}

^on #-topic 1 * {
  @ setitem(topic.$1 0 $2-)}

^on #-leave 1 * if ([$0] == N) {
  @ delitem(topic.$1 0)}

^on #-dcc_connect 23 "% CHAT % %" {
  addtab /m =$0}
^on #-msg 23 * {
    addtab /m $0
    ^hook ra m $0 ! $0 $userhost() $1-
    ^hook dlog msg $0 $userhost() $1-}
^on #-invite 23 * {
  ^hook ra i $0 ! $*
  ^hook dlog invite $*}
^on #-dcc_connect 23 * {
  ^hook dlog dcc_connect $1 $0 ! $2-}
^on #-ctcp 23 * {
  ^hook ra c $0 ! $0 $userhost() $1-
  ${[$1] == N ? [^hook dlog ctcp $0 $userhost() $fixcnick($1) $fixctcp($2-)] : }}
^on #-hook 23 "ctcp *" {
  echo $fparse(format_ctcp ! $1 $2 $fixcnick($3) $fixctcp($4-))
  ^hook ra c $1 ! $1 $2 $3-
  ${[$3] == N ? [^hook dlog ctcp $1 $2 $fixcnick($3) $fixctcp($4-)] : }}
^on ^notice * {
  if (wallchan($1)) {
    ^local wc $wallchan($1)
    xecho -win $chanwin($wallchan($1)) $fparse(format_bwall ! $wallchan($1) $0 ! $2-)
    addtab /wall $wc
    ^hook ra w $0 ! $wc $0 ! $2-} else {
    echo $fparse(format_notice ! $0 $userhost() $1-)
    ^hook ra n $0 ! $0 $userhost() $1-
    ${[$1-] !~ [You have % % waiting*] && [$1-] !~ [For a list, /MSG % NOTES [pass]*] ? [^hook dlog notice $0 $userhost() $1-]:}}}
^on #-dcc_error 23 * {
  ^hook dlog dcc_error $*}
^on #-connect 23 * {
  ^hook dlog connect $*}
^on #-disconnect 23 * {
  ^hook dlog disconnect $*}
^on #-kick 23 * {
  ${[$0] == N ? [^hook dlog kick_user $1 $2 ! $3-] : }}
^on #-ar_public 23 * {
   addtab $0\:
  ^hook ra p $0 ! $*
  ^hook dlog public_other_ar $*}
^on #-ar_public_other 23 * {
  ^hook ra p $0 ! $*
  ^hook dlog public_other_ar $*}
^on #-join 23 * {
  ${[$0]==N?[^hook dlog join $0 $userhost() $1]:}
  @ [$0] != N ? setitem(lj.$C 0 $0) :}
^on #-dcc_chat 23 * {
  addtab /m =$0
  ^hook ra d $0 ! $0 ! $1-
  ^hook dlog dcc_chat $0 ! $1-}
^on #-mode_stripped 23 * {
  ${[$2-]=~[*$N*]?[^hook dlog mode $0 ! $1-]:}}
^on ^send_msg * {
    addtab /m $0
    echo $fparse(format_send_msg ! $0 ! $1-)
    ^hook ra sm $0 ! $0 ! $1-}
^on #-send_notice 23 * {
  ^hook ra sn $0 ! $0 ! $1-}
^on #-send_dcc_chat 23 * {
  addtab /m =$0
  ^hook ra sd $0 ! $*}
^on #-public 22 * {
    ^hook ra p $0 ! $*}
^on #-public_other 23 * {
    ^hook ra p $0 ! $*}
^on #-send_public 23 * {
    ^hook ra sp $N ! ! $N $1-}
^on #-wallop 23 * {
  ^hook ra ow $0 ! $*}
^on #-ctcp_reply 23 * {
  ^hook ra cr $0 ! $0 ! $1-}
^on #-send_to_server 23 "% % INVITE % %" {
  ^hook ra si $3 ! $3 $4}
^on #-send_to_server 23 "% % PRIVMSG % :*" {
  if ([$4]!=[:DCC]&&[$4]!=[:ACTION]) {
    ^hook ra sc ${!ischannel($3)?[$3]:N} ! $3 $strip(: $4-)}}
alias ne {ge ${c.lc}$before(, $*)${c.lm}/${c.cl}$after(, $*)}
on ^305 * #
on ^306 * #
on ^401 * {ne $1,no such nick/channel.}
on ^402 * {ne $1,no such nick/server.}
on ^404 * {ne $1,can't send to channel.}
on ^406 * {ne $1,was never on IRC.}
on ^467 * {ne $1,channel key is already set.}
on ^473 * {  
  ^on ^329 * {
    ^on ^329 -*}
  ^on ^raw_irc "% 324 *" {
    ge $(c.lc)$3$(c.lm)/$(cl)invite only channel. $(c.lm)\($(cl)$4$(c.lm)\)$(cl)
    ^on ^raw_irc -"% 324 *"}
  mode $strip([] $1)}
on ^474 "*" {
  @bchan=[$1]
  ^on ^raw_irc "% 367 *" {
    @ [$N!$_uhost] =~ [$4] ? ge($(c.lc)$bchan$(c.lm)/$(cl)ban setby $before(! $5)$(c.hk)!$(cl)$after(! $5) $(c.lm)\($(cl)$4$(c.lm)\)$(cl)):}
  ^on ^raw_irc "* 368 *" {      
    ^on ^raw_irc -"% 367 *" 
    ^on ^raw_irc -"* 368 *"}
  mode $bchan +b}
on ^475 * {  
  ^on ^329 * {
    ^on ^329 -*}
  ^on ^raw_irc "% 324 *" {
    ge $(c.lc)$3$(c.lm)/$(cl)bad channel key. $(c.lm)\($(cl)$4$(c.lm)\)$(cl)
    ^on ^raw_irc -"% 324 *"}
  mode $strip([] $1)}
on ^329 * #
#sjk/psy'97
