;; /onthehour name /command
alias onthehour {
if ($isid) {
;; could do whatever here
return
}
;; cleanup incase the timer is being overwritten
if ($timer($1)) {
.timer $+ $1 off
}
if (%onthehour. [ $+ [ $1 ] ]) {
unset %onthehour. [ $+ [ $1 ] ]
}
;; set to 59secs to reduce the chance of timer skipping *:00; def not full proof
.timer $+ $1 -io 1 59 onthehourcheck $unsafe($1-)
}
// local: /onthehourcheck name /command
alias -l onthehourcheck {
if ($asctime(n) || %onthehour. [ $+ [ $1 ] ]) {
return
}
;; run the command
;; deviation: if the command errors, the timer is stopped unlike a typical 'forever' timer
$2-
;; update state so as not to allow the timer to trigger in the next 45 minutes
set -eu2700 %onthehour. [ $+ [ $1 ] ] $true
;; restart the timer
.timer $+ $1 -io 1 59 onthehourcheck $unsafe($1-)
}