From 26477e22d29e224969d0dba83ce9e9b580059fed Mon Sep 17 00:00:00 2001 Message-Id: <26477e22d29e224969d0dba83ce9e9b580059fed.1715815822.git.mdw@distorted.org.uk> From: Mark Wooding Date: Mon, 11 Feb 2002 18:26:15 +0000 Subject: [PATCH] Figured out what to do about tellme secure but register insecure. Implementing untell and delmsg. Organization: Straylight/Edgeware From: Ian Jackson --- bot.tcl | 111 ++++++++++++++++++++++++++++++++++++--------------- helpinfos | 7 ++-- parsecmd.tcl | 9 +++++ 3 files changed, 92 insertions(+), 35 deletions(-) diff --git a/bot.tcl b/bot.tcl index 29c0007..0fd2b75 100755 --- a/bot.tcl +++ b/bot.tcl @@ -235,7 +235,7 @@ FIXME - document the extra param to recordlastseen append evstate [string range $stt 0 0] append evstate [string range $event 0 0] - manyset [nickdb_get $n tellsec] sec secwhen + manyset [tell_effective_sec $n] sec secwhen switch -exact $sec { insecure { append evstate ii } secure { append evstate [expr {$ago<$secwhen ? "sl" : "ss"}] } @@ -417,7 +417,7 @@ proc chanmode_o1 {m g p chan} { } else { set chan_initialop([irctolower $chan]) $u sendprivmsg $n \ - "Thanks. You can use `channel manager ...' to register this channel." + "Thanks. You can use `channel manager ...' to register this channel." if {![nickdb_exists $n] || ![string length [nickdb_get $n username]]} { sendprivmsg $n \ "(But to do that you must register your nick securely first.)" @@ -767,7 +767,7 @@ def_somedb_id delete {} { set default_settings_nick { timeformat ks marktime off - tellsec insecure + tellsec {secure 600} tellrel {remind 3600 30} } @@ -1182,14 +1182,57 @@ def_ucmd channel { channel/$subcmd } +proc tell_effective_sec {n} { + set l [nickdb_get $n tellsec] + set u [nickdb_get $n username] + if {"[lindex $l 0]" == "secure" && ![string length $u]} { set l insecure } + return $l +} + +proc tell_peernicks { +-- FIXME HERE + +def_ucmd untell { + prefix_nick + check_notonchan + nick_securitycheck 0 + set peernicks + def_ucmd delmsg { + global errorInfo errorCode prefix_nick check_notonchan - manyset [nickdb_get $n tellsec] sec + manyset [tell_effective_sec $n] sec secwhen switch -exact $sec { insecure { } - refuse - mailto { error "you cannot - if {"$sec" == " + refuse - mailto { + usererror \ + "There are no messages to delete\ + because your message disposition prevents them from being left." + } + secure { + nick_securitycheck 1 + } + default { + error "delmsg sec $sec" + } + } + set text [irctolower [string trim $text]] + set senders [split $text " "] + foreach sender $senders { + if {[catch { check_nick $sender } emsg]} { + error "invalid sender nick `$sender': $emsg" $errorInfo $errorCode + } + } + tell_delete_msgs [irctolower $senders] [irctolower $n] + switch -exact [llength $senders] { + 0 { ucmdr {} {} "deletes your message(s)." } + 1 { ucmdr {} {} "deletes your message(s) from $senders." } + default { + ucmdr {} {} "deletes your message(s) from\ + [lreplace $senders end end] and [lindex $senders end]." + } + } } def_ucmd tell { @@ -1204,7 +1247,7 @@ def_ucmd tell { set ctarget $target if {[info exists nick_case($ltarget)]} { set ctarget $nick_case($ltarget) } - manyset [nickdb_get $target tellsec] sec mailtoint mailwhy + manyset [tell_effective_sec $target] sec mailtoint mailwhy manyset [nickdb_get $target tellrel] rel relint relwithin switch -exact $sec { insecure - secure { @@ -1374,15 +1417,22 @@ proc def_setting {opt show_body set_body} { $set_body" } -proc tellme_sec_desc {v} { +proc tellme_sec_desc {v n} { manyset $v sec mailtoint switch -exact $sec { insecure { return "I'll tell you your messages whenever I see you." } secure { - return \ + if {[string length [nickdb_get $n username]]} { + return \ "I'll keep the bodies of your messages private until you identify yourself, reminding you every [showintervalsecs $mailtoint 1]." + } else { + return \ + "I'll tell you your messages whenever I see you.\ + (Secure message delivery is enabled, but your nick is not registered\ + securely. See `help register'.)" + } } refuse { return "I shan't accept messages for you." @@ -1466,13 +1516,7 @@ 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 {} { +proc tellme_setting_sec_simple {} { uplevel 1 { ta_nomore set sr sec @@ -1480,16 +1524,17 @@ proc telling_setting_sec_simple {} { } } -proc telling_setting_neednomsgs {} { +proc tellme_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] + set ms [tellme_sec_desc $secv $n] manyset $secv sec switch -exact $sec { insecure - secure { @@ -1504,22 +1549,26 @@ def_setting tellme { set setting [string tolower [ta_word]] switch -exact $setting { insecure { - telling_setting_sec_simple + tellme_setting_sec_simple } secure { - telling_setting_sec_simple + set every [ta_interval_optional 60 600] + ta_nomore + set sr sec + set v [list secure $every] } refuse { telling_setting_neednomsgs telling_setting_sec_simple } mailto { -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 u [nickdb_get $n username] + if {[string length $u]} { + usererror \ + "Sorry, you must register securely to have your messages mailed\ + (to prevent the use of this feature for spamming). See `help register'." + } set sr sec set v [list mailto [ta_word] $u] } @@ -1527,21 +1576,19 @@ FIXME - what if user makes themselves insecure or deletes themselves while they manyset [nickdb_get $n tellsec] sec switch -exact $sec { refuse - mailto { - error "can't change message delivery conditions when message disposition prevents messages from being left" + usererror \ + "You can't change your message delivery conditions when\ + your message disposition prevents messages from being left." } } set sr rel set v $setting if {"$setting" != "unreliable"} { - set every [parse_interval [ta_word] 300] + set every [parse_interval_optional 300 3600] lappend v $every } if {"$setting" == "remind"} { - if {[ta_anymore]} { - set within [parse_interval [ta_word] 5] - } else { - set within 30 - } + set within [ta_interval_optional 5 30] if {$within > $every} { error "remind interval must be at least time to respond" } diff --git a/helpinfos b/helpinfos index 7d05c43..3e478b4 100644 --- a/helpinfos +++ b/helpinfos @@ -41,13 +41,14 @@ tell :tellme !tellme repeats any messages you have outstanding. !set tellme configures how you receive messages sent with !tell: - set tellme insecure When I see you. (Default.) + set tellme insecure When I see you. set tellme secure [] Hide body (reminding) until ident. set tellme refuse Do not accept messages. set tellme mailto By email. (Secure nicks only.) -and also when to consider them delivered (see `help !untell'): +Default: `secure 600'. For insecure nicks `secure' == `insecure'. +To set when to consider messages delivered (see `help !untell'): set tellme unreliable Tell you once, then forget. - set tellme remind [] + set tellme remind [ []] Remind until you talk on channel within of me having told you. (Default is remind 1h 30s.) set tellme pester Remind until you say !delmsg diff --git a/parsecmd.tcl b/parsecmd.tcl index de8d322..d7fba69 100644 --- a/parsecmd.tcl +++ b/parsecmd.tcl @@ -23,6 +23,15 @@ proc ta_nick {} { return $v } +proc ta_interval_optional {min def} { + upvar 1 text text + if {[ta_anymore]} { + return [parse_interval [ta_word] $min] + } else { + return $def + } +} + proc usererror {emsg} { error $emsg {} {BLIGHT USER} } proc go_usercommand {p c n dest text} { -- [mdw]