From: Ian Jackson Date: Mon, 4 Sep 2000 14:13:53 +0000 (+0000) Subject: Various userdb stuff. X-Git-Tag: branchpoint-2001-10-09-tell~64 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/ircbot/commitdiff_plain/a69f7d2cdd3d10cded90b734f0557dc8e4d323c7 Various userdb stuff. --- diff --git a/bot.tcl b/bot.tcl index f03c183..8d8d0c2 100755 --- 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 \