+ append ol "\nYou aren't on any channels with me."
+ }
+ } elseif {![info exists nu]} {
+ append ol "\n$nshow has not identified themselves."
+ } elseif {![info exists username]} {
+ append ol "\n$nshow has identified themselves as the user $nu."
+ } elseif {"$nu" != "$username"} {
+ append ol "\nHowever, $nshow is being used by the user $nu."
+ } else {
+ append ol "\n$nshow has identified themselves to me."
+ }
+ ucmdr {} $ol
+}
+
+def_ucmd register {
+ prefix_nick
+ check_notonchan
+ set old [nickdb_exists $n]
+ if {$old} { nick_securitycheck 0 }
+ set luser [irctolower $n]
+ switch -exact [string tolower [string trim $text]] {
+ {} {
+ upvar #0 nick_username($luser) nu
+ if {![info exists nu]} {
+ ucmdr {} \
+ "You must identify yourself before using `register'. See `help identify', or use `register insecure'."
+ }
+ nickdb_set $n username $nu
+ ucmdr {} {} "makes a note of your username." {}
+ }
+ delete {
+ nickdb_delete $n
+ ucmdr {} {} "forgets your nickname." {}
+ }
+ insecure {
+ nickdb_set $n username {}
+ if {$old} {
+ ucmdr {} "Security is now disabled for your nickname !"
+ } else {
+ ucmdr {} "This is fine, but bear in mind that people will be able to mess with your settings. Channel management features need a secure registration." "makes an insecure registration for your nick."
+ }
+ }
+ default {
+ error "you mean register / register delete / register insecure"
+ }
+ }
+}
+
+proc timeformat_desc {tf} {
+ switch -exact $tf {
+ ks { return "Times will be displayed in seconds or kiloseconds." }
+ hms { return "Times will be displayed in hours, minutes, etc." }
+ default { error "invalid timeformat: $v" }
+ }
+}
+
+set settings {}
+proc def_setting {opt show_body set_body} {
+ global settings
+ lappend settings $opt
+ proc set_show/$opt {} "
+ upvar 1 n n
+ set opt $opt
+ $show_body"
+ if {![string length $set_body]} return
+ proc set_set/$opt {} "
+ upvar 1 n n
+ upvar 1 text text
+ set opt $opt
+ $set_body"
+}
+
+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 {
+ 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."
+ }
+ mailto {
+ return "I'll forward your messages by email to $mailtoint."
+ }
+ default {
+ error "bad tellsec $sec"
+ }
+ }
+}
+
+proc tellme_rel_desc {v} {
+ manyset $v rel every within
+ switch -exact $rel {
+ unreliable {
+ return "As soon as I've told you, I'll forget the message - note that this means messages can get lost !"
+ }
+ pester {
+ set u {}
+ }
+ remind {
+ set u ", or talk on channel within [showintervalsecs $within 1] of me having told you"
+ }
+ default {
+ error "bad tellrel $rel"
+ }
+ }
+ return "I'll remind you every [showintervalsecs $every 1] until you say delmsg$u."
+}
+
+def_setting timeformat {
+ set tf [nickdb_get $n timeformat]
+ return "$tf: [timeformat_desc $tf]"
+} {
+ set tf [string tolower [ta_word]]
+ ta_nomore
+ set desc [timeformat_desc $tf]
+ nickdb_set $n timeformat $tf
+ ucmdr {} $desc
+}
+
+proc marktime_desc {mt} {
+ if {"$mt" == "off"} {
+ return "I will not send you periodic messages."
+ } elseif {"$mt" == "once"} {
+ return "I will send you one informational message when I see you."
+ } else {
+ return "I'll send you a message every [showintervalsecs $mt 0]."
+ }
+}
+
+def_setting marktime {
+ set mt [nickdb_get $n marktime]
+ set p $mt
+ if {[string match {[0-9]*} $mt]} { append p s }
+ append p ": "
+ append p [marktime_desc $mt]
+ return $p
+} {
+ global marktime_min
+ set mt [string tolower [ta_word]]
+ ta_nomore
+
+ if {"$mt" == "off" || "$mt" == "once"} {
+ } else {
+ set mt [parse_interval $mt $marktime_min]
+ }
+ nickdb_set $n marktime $mt
+ lnick_marktime_start [irctolower $n] "So:" 500 0
+ ucmdr {} [marktime_desc $mt]
+}
+
+def_setting security {
+ set s [nickdb_get $n username]
+ if {[string length $s]} {
+ return "Your nick, $n, is controlled by the user $s."
+ } else {
+ return "Your nick, $n, is not secure."
+ }
+} {}
+
+proc tellme_setting_sec_simple {} {
+ uplevel 1 {
+ ta_nomore
+ set sr sec
+ set v $setting
+ }
+}
+
+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 $n]
+ manyset $secv sec
+ switch -exact $sec {
+ insecure - secure {
+ set mr [tellme_rel_desc [nickdb_get $n tellrel]]
+ return "$ms $mr"
+ }
+ refuse - mailto {
+ return $ms
+ }
+ }
+} {
+ set setting [string tolower [ta_word]]
+ switch -exact $setting {
+ insecure {
+ tellme_setting_sec_simple
+ }
+ secure {
+ 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 {
+ telling_setting_neednomsgs
+ 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]
+ }
+ unreliable - pester - remind {
+ manyset [nickdb_get $n tellsec] sec
+ switch -exact $sec {
+ refuse - mailto {
+ 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_optional 300 3600]
+ lappend v $every
+ }
+ if {"$setting" == "remind"} {
+ set within [ta_interval_optional 5 30]
+ if {$within > $every} {
+ error "remind interval must be at least time to respond"
+ }
+ lappend v $within
+ }
+ ta_nomore
+ }
+ default {
+ error "invalid tellme setting $setting"