Merge pull request 'Rowbot Enhancements' (#14) from rowbot-enhanced into master

Reviewed-on: #14
This commit is contained in:
Nick Chambers 2021-07-01 19:08:53 +00:00
commit 3fb52e90fc
1 changed files with 26 additions and 26 deletions

View File

@ -1,27 +1,26 @@
#!/usr/bin/env bash
###
# stats
# lore
###
if [[ ! -v START_TIME ]]; then
export START_TIME
printf -v START_TIME '%(%s)T' -1
export LORE_THIS_RELOAD
printf -v LORE_THIS_RELOAD '%(%s)T' -1
if [[ ! -v LORE_START_TIME ]]; then
export LORE_START_TIME=$LORE_THIS_RELOAD
fi
if [[ -v RELOADED ]]; then
(( RELOADED += 1 ))
if [[ ! -v LORE_LONGEST_LIFE ]]; then
export LORE_LONGEST_LIFE=0
elif (( LORE_LONGEST_LIFE < SECONDS )); then
export LORE_LONGEST_LIFE=$SECONDS
fi
if [[ -v LORE_LIVES ]]; then
(( LORE_LIVES += 1 ))
else
export RELOADED=0
fi
export LAST_RELOAD
printf -v LAST_RELOAD '%(%s)T' -1
if [[ ! -v LONGEST_LIFE ]]; then
export LONGEST_LIFE=0
elif (( LONGEST_LIFE < SECONDS )); then
export LONGEST_LIFE=$SECONDS
export LORE_LIVES=1
fi
###
@ -431,8 +430,8 @@ config-reload() {
export "${env_var^^}"="${!env_var}"
done
if (( SECONDS > LONGEST_LIFE )); then
export LONGEST_LIFE=$SECONDS
if (( SECONDS > LORE_LONGEST_LIFE )); then
export LORE_LONGEST_LIFE=$SECONDS
fi
info "reloading rowbot"
@ -1012,8 +1011,8 @@ hook_cmd_control_panel() {
export "${env_var^^}"="${!env_var}"
done
if (( SECONDS > LONGEST_LIFE )); then
export LONGEST_LIFE=$SECONDS
if (( SECONDS > LORE_LONGEST_LIFE )); then
export LORE_LONGEST_LIFE=$SECONDS
fi
privmsg "$to" "reloading..."
@ -1059,17 +1058,18 @@ hook_cmd_control_panel() {
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")"
dashboard|lore)
declare -p LORE_LONGEST_LIFE
privmsg "$to" "legend began on $(printf '%(%c)T' "$LORE_START_TIME")"
privmsg "$to" "this life began on $(printf '%(%c)T' "$LORE_THIS_RELOAD")"
if (( LONGEST_LIFE > SECONDS )); then
privmsg "$to" "longest life so far is $(seconds "$LONGEST_LIFE")"
if (( LORE_LONGEST_LIFE > SECONDS )); then
privmsg "$to" "longest life so far was $(seconds "$LORE_LONGEST_LIFE")"
else
privmsg "$to" "longest life so far is $(seconds "$SECONDS") (this one)"
fi
privmsg "$to" "reloaded $RELOADED times"
privmsg "$to" "lived $LORE_LIVES times"
esac
}