From 425f3fef7a9ade3938435659bfa61ba5f95f491c Mon Sep 17 00:00:00 2001 From: Nick Chambers Date: Thu, 24 Jun 2021 21:11:37 -0500 Subject: [PATCH] Add some stats tracking --- rowbot | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/rowbot b/rowbot index bf49fe2..25012cd 100755 --- a/rowbot +++ b/rowbot @@ -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 }