chiark / gitweb /
Working on !tell. Look at def_setting tellme for fixmes
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 11 Feb 2002 17:01:54 +0000 (17:01 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 11 Feb 2002 17:01:54 +0000 (17:01 +0000)
bot.tcl

diff --git a/bot.tcl b/bot.tcl
index 315163fd8e02284a849a5d9ed7b0600e8dba6a9d..29c000788ad2492e57cab2adb4febf8b336d9040 100755 (executable)
--- a/bot.tcl
+++ b/bot.tcl
@@ -150,6 +150,8 @@ proc tell_event {nl event} {
     # that here.  Also, here we turn `talk' into `talk' now and `act'
     # later.  We also support the psuedo-event `none'.  The del msg
     # and new msg events are handled by the command procedures, not here.
+    global calling_nick
+    if {[info exists calling_nick] { set save $calling_nick }
     switch -exact $event {
        none { }
        talk {
@@ -166,15 +168,17 @@ proc tell_event {nl event} {
            error "tell_event $nl $event"
        }
     }
+    if {[info exists save]} { set calling_nick $save }
 }
 
 proc tell_event_core {nl event} {
     # event is `talk', `act' or `ident'
     # When user talks we actually get talk now and act later
 FIXME - implement all cmds
-FIXME - implement pass stuff       set stt [list $u passed $now]
 FIXME - implement tells_delete_msgs catch { unset stt }   ?
 FIXME - document the extra param to recordlastseen
+    global calling_nick
+    set calling_nick $nl
     set iml [msgdb_get $nl inbound]
     if {![llength $iml]} return
 
@@ -269,9 +273,26 @@ FIXME - document the extra param to recordlastseen
        }
        ni????? - naii??? - nas?i?? - mi????? - pa????l {
            # pass and then stuff
-           
-
-           return
+           if {[length $iml] == 3} {
+               manyset $iml sender sentwhen msg
+               sendprivmsg $nl \
+ "$sender asked me [showintervalsecs [expr {$now-$sentwhen}] 0]\
+ to tell you: $msg"
+            } else {
+               sendprivmsg $nl \
+ "Here are the [expr {[llength $iml]/3}] messages there are for you:"
+               while {[llength $iml] >= 3} {
+                   manyset [lrange $iml 0 2] sender sentwhen msg
+                   set iml [lrange $iml 3 end]
+                   sendprivmsg $nl \
+ " [showintervalsecs [expr {$now-$sentwhen}] 1] <$sender> $msg"
+               }
+           }
+           if {"$rel" == "unreliable"} {
+               tell_delete_msgs {} $nl
+               return
+           }
+           set stt passed
        }
        nas?u?? {
            sendprivmsg $nl {You have messages (so identify yourself please).}]
@@ -749,11 +770,6 @@ set default_settings_nick {
     tellsec insecure
     tellrel {remind 3600 30}
 }
-# also:
-#  inbound: concatenation of many   sender time_t text
-#  outbound: concatenation of many   recipient time_t count
-#   neither are sorted particularly; only one entry per recipient in
-#   output; both sender and recipient are cased
 
 set default_settings_chan {
     autojoin 1
@@ -770,6 +786,8 @@ set default_settings_msgs {
 }
 # inbound -> [<nick> <time_t> <message>] ...
 # outbound -> [<nick> <time_t(earliest)> <count>] ...
+#   neither are sorted particularly; only one entry per recipient in
+#   output; both sender and recipient are cased
 
 def_somedb_id set {args} {
     upvar #0 default_settings_$nickchan def
@@ -1164,12 +1182,23 @@ def_ucmd channel {
     channel/$subcmd
 }
 
+def_ucmd delmsg {
+    prefix_nick
+    check_notonchan
+    manyset [nickdb_get $n tellsec] sec
+    switch -exact $sec {
+       insecure { }
+       refuse - mailto { error "you cannot 
+    if {"$sec" == "
+}
+
 def_ucmd tell {
     global nick_case ownmailaddr ownfullname
     
     prefix_nick
     set target [ta_word]
     if {![string length $text]} { error "tell them what?" }
+    if {[string length $text] > 400} { error "message too long" }
 
     set ltarget [irctolower $target]
     set ctarget $target
@@ -1437,6 +1466,27 @@ def_setting security {
     }
 } {}
 
+proc tellme_setting_needsecure {n ue} {
+    set u [nickdb_get $n username]
+    if {[string length $u]} { usererror $ue }
+    return $u
+}
+
+proc telling_setting_sec_simple {} {
+    uplevel 1 {
+       ta_nomore
+       set sr sec
+       set v $setting
+    }
+}
+
+proc telling_setting_neednomsgs {} {
+    uplevel 1 {
+       if {[llength [msgsdb_get $n inbound]]} {
+           usererror "You must delete the messages you have, first."
+       }
+    }
+
 def_setting tellme {
     set secv [nickdb_get $n tellsec]
     set ms [tellme_sec_desc $secv]
@@ -1453,19 +1503,23 @@ def_setting tellme {
 } {
     set setting [string tolower [ta_word]]
     switch -exact $setting {
-       insecure - secure - refuse {
-           ta_nomore
-           if {"$setting" == "refuse" && [llength [msgsdb_get $n inbound]]} {
-               usererror "You must delete the messages you have, first."
-           }
-           set sr sec
-           set v $setting
+       insecure {
+           telling_setting_sec_simple
+       }
+       secure {
+           telling_setting_sec_simple
+       }
+       refuse {
+           telling_setting_neednomsgs
+           telling_setting_sec_simple
        }
        mailto {
-           set u [nickdb_get $n username]
-           if {![string length $u]} {
-               usererror "Sorry, you must register secure to have your messages mailed (to prevent the use of this feature for spamming)."
-           }
+FIXME - working here, check needsecure for secure
+FIXME - what if user makes themselves insecure or deletes themselves while they have msgs ?
+           telling_setting_neednomsgs
+           set u [tellme_setting_needsecure $n \
+ "Sorry, you must register secure to have your messages mailed\
+ (to prevent the use of this feature for spamming)."]
            set sr sec
            set v [list mailto [ta_word] $u]
        }