From 260aab1fd3a5c70f5b6085946978681dc2ed347e Mon Sep 17 00:00:00 2001 From: steering7253 Date: Wed, 26 Nov 2025 16:05:37 -0700 Subject: space2tab --- remind.tcl | 450 ++++++++++++++++++++++++++++++------------------------------- tell.tcl | 140 +++++++++---------- 2 files changed, 295 insertions(+), 295 deletions(-) diff --git a/remind.tcl b/remind.tcl index edd6fd7..5593ef9 100644 --- a/remind.tcl +++ b/remind.tcl @@ -8,14 +8,14 @@ # Usage: # !remind nick time message # - creates a new reminder for nick in the -# current channel at time with message +# current channel at time with message # - time is a format parseable by the tcl -# command 'clock scan'. If the time consists -# of several words, it has to be enclosed -# in "". +# command 'clock scan'. If the time consists +# of several words, it has to be enclosed +# in "". # - examples: -# !remind morbaq "tomorrow 10:00" Call Peter -# !remind morbaq "2009-12-31 23:59" Happy new year! +# !remind morbaq "tomorrow 10:00" Call Peter +# !remind morbaq "2009-12-31 23:59" Happy new year! # # !reminders # - lists all active reminders @@ -23,11 +23,11 @@ # !cancelReminder id # - cancels the reminder with id # - the id is the number preceeding the -# reminder in the list produced by -# !reminders +# reminder in the list produced by +# !reminders # - note: the id may change as new reminders -# are added or old reminders removed. Always -# check the id just before cancelling +# are added or old reminders removed. Always +# check the id just before cancelling # # ################################################ @@ -51,262 +51,262 @@ array set reminders {} # save to file proc saveReminders {} { - global reminders - global datafile + global reminders + global datafile - set file [open $datafile w+] - puts $file [array get reminders] - close $file + set file [open $datafile w+] + puts $file [array get reminders] + close $file } # the run-at-time procedure proc at {time args} { - if {[llength $args]==1} { - set args [lindex $args 0] - } - set dt [expr {($time - [clock seconds])*1000}] - return [after $dt $args] + if {[llength $args]==1} { + set args [lindex $args 0] + } + set dt [expr {($time - [clock seconds])*1000}] + return [after $dt $args] } proc printReminder {reminderId {tonick ""} {fire "false"}} { - global reminders - - # get the reminder - set reminder $reminders($reminderId) - - set when [clock format [lindex $reminder 0] -format "%Y-%m-%dT%H:%M:%SZ"] - set chan [lindex $reminder 1] - set who [lindex $reminder 2] - set timer [lindex $reminder 3] - set what [lindex $reminder 4] - - if {$fire} { - putserv "PRIVMSG $chan :\[remind\] $who: $what" - } else { - putserv "NOTICE $tonick :\[remind\] $reminderId: for $who at $when: $what" - } + global reminders + + # get the reminder + set reminder $reminders($reminderId) + + set when [clock format [lindex $reminder 0] -format "%Y-%m-%dT%H:%M:%SZ"] + set chan [lindex $reminder 1] + set who [lindex $reminder 2] + set timer [lindex $reminder 3] + set what [lindex $reminder 4] + + if {$fire} { + putserv "PRIVMSG $chan :\[remind\] $who: $what" + } else { + putserv "NOTICE $tonick :\[remind\] $reminderId: for $who at $when: $what" + } } proc fireReminder {reminderId} { - global reminders + global reminders - printReminder $reminderId "" "true" - unset reminders($reminderId) - saveReminders + printReminder $reminderId "" "true" + unset reminders($reminderId) + saveReminders } proc pub:clockscan {nick host handle chan text} { - set timeError "" - # parse parameters - set curTime [clock format [clock seconds] -format "%H:%M:%SZ" -gmt 1] - regsub -all {([0-9]+)y$} $text "\\1 years $curTime" text - regsub -all {([0-9]+)mo$} $text "\\1 months $curTime" text - regsub -all {([0-9]+)w$} $text "\\1 weeks $curTime" text - regsub -all {([0-9]+)d$} $text "\\1 days $curTime" text - regsub -all {([0-9]+)hr?$} $text {\1 hours} text - regsub -all {([0-9]+)m$} $text {\1 minutes} text - regsub -all {([0-9]+)s$} $text {\1 seconds} text - set time [catch {clock scan $text} timeResult] - - if {$time != 0} { - putserv "NOTICE $chan :\[remind\] unable to parse time: $timeResult" - return 1 - } - - set ISOTimeResult [clock format $timeResult -format "%Y-%m-%dT%H:%M:%SZ" -gmt 1] - - if {[clock seconds] > $timeResult} { - putserv "NOTICE $chan :\[clockscan\] error: \"$text\" (parsed as $timeResult → $ISOTimeResult) is in the past" - return 1 - } - - putserv "NOTICE $chan :\[clockscan\] parsed \"$text\" as $timeResult → $ISOTimeResult" + set timeError "" + # parse parameters + set curTime [clock format [clock seconds] -format "%H:%M:%SZ" -gmt 1] + regsub -all {([0-9]+)y$} $text "\\1 years $curTime" text + regsub -all {([0-9]+)mo$} $text "\\1 months $curTime" text + regsub -all {([0-9]+)w$} $text "\\1 weeks $curTime" text + regsub -all {([0-9]+)d$} $text "\\1 days $curTime" text + regsub -all {([0-9]+)hr?$} $text {\1 hours} text + regsub -all {([0-9]+)m$} $text {\1 minutes} text + regsub -all {([0-9]+)s$} $text {\1 seconds} text + set time [catch {clock scan $text} timeResult] + + if {$time != 0} { + putserv "NOTICE $chan :\[remind\] unable to parse time: $timeResult" + return 1 + } + + set ISOTimeResult [clock format $timeResult -format "%Y-%m-%dT%H:%M:%SZ" -gmt 1] + + if {[clock seconds] > $timeResult} { + putserv "NOTICE $chan :\[clockscan\] error: \"$text\" (parsed as $timeResult → $ISOTimeResult) is in the past" + return 1 + } + + putserv "NOTICE $chan :\[clockscan\] parsed \"$text\" as $timeResult → $ISOTimeResult" } proc pub:newReminderfornick {nick host handle chan text} { - global reminders - - - set timeError "" - # parse parameters - set id [clock seconds] - set who $nick - set when [lindex $text 0] - set curTime [clock format [clock seconds] -format "%H:%M:%SZ" -gmt 1] - regsub -all {([0-9]+)y$} $when "\\1 years $curTime" when - regsub -all {([0-9]+)mo$} $when "\\1 months $curTime" when - regsub -all {([0-9]+)w$} $when "\\1 weeks $curTime" when - regsub -all {([0-9]+)d$} $when "\\1 days $curTime" when - regsub -all {([0-9]+)hr?$} $when {\1 hours} when - regsub -all {([0-9]+)m$} $when {\1 minutes} when - regsub -all {([0-9]+)s$} $when {\1 seconds} when - set time [catch {clock scan $when} timeResult] - set what [lrange $text 1 end] - - if {$when == ""} { - putserv "NOTICE $chan :\[remind\] !remindme \"