From 268336f83b608ff02f8460594da04b0d540ebbd4 Mon Sep 17 00:00:00 2001 Message-Id: <268336f83b608ff02f8460594da04b0d540ebbd4.1715732217.git.mdw@distorted.org.uk> From: Mark Wooding Date: Mon, 11 Feb 2002 17:01:54 +0000 Subject: [PATCH] Working on !tell. Look at def_setting tellme for fixmes Organization: Straylight/Edgeware From: Ian Jackson --- bot.tcl | 94 +++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 74 insertions(+), 20 deletions(-) diff --git a/bot.tcl b/bot.tcl index 315163f..29c0007 100755 --- 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 -> [ ] ... # outbound -> [ ] ... +# 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] } -- [mdw]