+proc prefix_nick {} {
+ global nick
+ upvar 1 p p
+ upvar 1 n n
+ if {![regexp {^([^!]+)!} $p dummy n]} { error "not from nick" }
+ check_nick $n
+ if {"[string tolower $n]" == "$nick"} { error "from myself" }
+}
+
+proc msg_PRIVMSG {p c dest text} {
+ prefix_nick
+ if {[regexp {^[&#+!]} $dest]} {
+ set what "!..."
+ set them it
+ } else {
+ set what "private messages"
+ set them them
+ }
+ sendout PRIVMSG $n \
+ "I will respond to $what at some point; for now I just log $them."
+}
+
+if {![info exists sock]} {
+ set sock [socket $host $port]
+ fconfigure $sock -buffering line
+ #fconfigure $sock -translation binary
+ fconfigure $sock -translation crlf
+
+ sendout USER guest 0 * "chiark testing bot"
+ sendout NICK $nick
+ fileevent $sock readable onread
+}