#!/bin/env tclsh
lappend auto_path /usr/lib/tcllib1.21
package require logger
set log [logger::init tclircc]
source irc.tcl
source cap.tcl
#puts "connecting to testnet.ergo.chat"
#set chan [irc::connect testnet.ergo.chat 6697 1]
set chan [irc::connect localhost 8000 0]
irc::handler add $chan * {
${log}::debug [dict get $dispatch rawmsg]
}
#irc::handler add $chan CAP {
# ${log}::debug "parsing cap ls"
# set parsed [cap::parse_msg [dict get $dispatch params]]
# dict for {k v} $parsed {
# if {$k == "caps"} {
# ${log}::debug "$k:"
# dict for {k v} $v {
# ${log}::debug " $k: $v"
# }
# } else {
# ${log}::debug "$k: $v"
# }
# }
#}
cap::negotiate $chan
cap::support $chan message-tags
puts [irc::meta get $chan]
irc::listen on $chan
#${log}::info "requesting CAPs"
#irc::msg send $chan CAP LS 302
${log}::info "entering event loop"
vwait nil