Throw away password-based userdb stuff.
[ircbot] / bot.tcl
diff --git a/bot.tcl b/bot.tcl
index 54cda63..bef0ead 100755 (executable)
--- a/bot.tcl
+++ b/bot.tcl
@@ -3,6 +3,17 @@
 set host chiark
 set port 6667
 if {![info exists nick]} { set nick Blight }
+if {![info exists ownfullname]} { set ownfullname "here to Help" }
+set ownmailaddr blight@chiark.greenend.org.uk
+
+if {![info exists globalsecret]} {
+    set gsfile [open /dev/urandom r]
+    fconfigure $gsfile -translation binary
+    set globalsecret [read $gsfile 32]
+    binary scan $globalsecret H* globalsecret
+    close $gsfile
+    unset gsfile
+}
 
 proc sendout {command args} {
     global sock
@@ -49,7 +60,6 @@ proc onread {args} {
     global sock
     
     if {[gets $sock line] == -1} { set terminate 1; return }
-binary scan $line H* inhex; puts >$inhex<
     regsub -all "\[^ -\176\240-\376\]" $line ? line
     set org $line
     if {[regexp -nocase {^:([^ ]+) (.*)} $line dummy prefix remain]} {
@@ -375,16 +385,20 @@ proc def_ucmd {cmdname body} {
 proc ucmdr {priv pub args} {
     return -code return [concat [list $priv $pub] $args]
 }
-    
-def_ucmd help {
-    ta_nomore
+
+proc ucmd_sendhelp {} {
     ucmdr \
 {Commands currently understood:
-help              get this list of commands
-seen <nick>       ask after someone (I'll tell them you asked)
-summon <username> invite a logged-on user onto IRC} {}
+ help              get this list of commands
+ seen <nick>       ask after someone (I'll tell them you asked)
+ summon <username> invite a logged-on user onto IRC
+Send commands to be by /msg, or say them in channel with ! in front.} {}
 }
 
+def_ucmd help { ta_nomore; ucmd_sendhelp }
+
+def_ucmd ? { ta_nomore; ucmd_sendhelp }
+
 proc manyset {list args} {
     foreach val $list var $args {
        upvar 1 $var my
@@ -421,7 +435,7 @@ def_ucmd summon {
        error $rv
     }
     if {[regexp {^problem (.*)} $rv dummy problem]} {
-       ucmdr {} "$target $problem."
+       ucmdr {} "The user `$target' $problem."
     } elseif {[regexp {^ok ([^ ]+) ([0-9]+)$} $rv dummy tty idlesince]} {
        set idletime [expr {$now - $idlesince}]
        set ls $now
@@ -435,6 +449,8 @@ def_ucmd summon {
     }
 }
 
+proc md5sum {value} { exec md5sum << $value }
+
 def_ucmd seen {
     global lastseen nick
     prefix_nick
@@ -473,7 +489,7 @@ if {![info exists sock]} {
     #fconfigure $sock -translation binary
     fconfigure $sock -translation crlf
 
-    sendout USER guest 0 * "chiark testing bot"
+    sendout USER blight 0 * $ownfullname
     sendout NICK $nick
     fileevent $sock readable onread
 }