chiark / gitweb /
Various userdb stuff.
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 4 Sep 2000 14:13:53 +0000 (14:13 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 4 Sep 2000 14:13:53 +0000 (14:13 +0000)
bot.tcl

diff --git a/bot.tcl b/bot.tcl
index f03c1832e6f86a361aa68a357e13db9d8b2397e7..8d8d0c24523c0275d63045ea725ccfeb3756f258 100755 (executable)
--- a/bot.tcl
+++ b/bot.tcl
@@ -3,8 +3,8 @@
 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
-set ownfullname "here to Help"
 
 if {![info exists globalsecret]} {
     set gsfile [open /dev/urandom r]
@@ -449,14 +449,23 @@ def_ucmd summon {
     }
 }
 
+proc userdb_exists {n} {
+    
+    binary scan [irctolower $n] H* nhex
+    return [file exists users/$nhex]
+}
+
+proc md5sum {value} { exec md5sum << $value }
+
+# proc userdb_store {n args} {   }
+
 def_ucmd newuser {
     global ownmailaddr ownfullname nick globalsecret
     prefix_nick
     if {[ischan $dest]} {
        error "You must register privately."
     }
-    binary scan [irctolower $n] H* nhex
-    if {[file exists users/$nhex]} {
+    if {[userdb_exists $n]} {
        error "You (or someone else) have already registered the nick $n."
     }
     set ownermail [ta_word]
@@ -468,18 +477,20 @@ def_ucmd newuser {
     set kmod [expr {$ksecs % $mult}]
 
     if {[string length $text]} {
-       if {![regexp -nocase {^([0-5])([0-9a-f]+)$} $text pass_sup kmod]} {
+       if {![regexp -nocase {^([0-5])[0-9a-f]+\s+(.*)$} $text pass_sup kmod text]} {
+           error ...
        }
        set ksecs [expr {(($ksecs - $kmod) / $mult) * 6 + $kmod}]
     }
-    set tohash "$ksecs\n$ownermail\n"
-    set hash [exec md5sum << $tohash]
+    set hash [md5sum "$ksecs\n$ownermail\n"]
     set passwd "$kmod[string range $hash 0 15]"
 
     if {[info exists pass_sup]} {
        if {"$passwd" != "$pass_sup"} {
            error "Incorrect registration password."
        }
+       userdb_store $n \
+               
        sendaction $n "ignores your ok"
     } else {
        set mailmsg \