Add some stats tracking

This commit is contained in:
Nick Chambers 2021-06-24 21:11:37 -05:00
parent 14c4feb9df
commit 425f3fef7a
1 changed files with 23 additions and 0 deletions

23
rowbot
View File

@ -1,5 +1,23 @@
#!/usr/bin/env bash
###
# stats
###
if [[ ! -v START_TIME ]]; then
export START_TIME
printf -v START_TIME '%(%s)T' -1
fi
if [[ -v RELOADED ]]; then
(( RELOADED += 1 ))
else
export RELOADED=0
fi
export LAST_RELOAD
printf -v LAST_RELOAD '%(%s)T' -1
###
# switch toggler
###
@ -939,6 +957,11 @@ hook_cmd_control_panel() {
read -r msg <<< "$msg"
privmsg "$recipient" "$msg"
privmsg "$to" "sent message to $recipient"
;;
stats)
privmsg "$to" "running since $(printf '%(%c)T' "$START_TIME")"
privmsg "$to" "last reload at $(printf '%(%c)T' "$LAST_RELOAD")"
privmsg "$to" "reloaded $RELOADED times"
esac
}