From 12157b380d5e6758d39d05c36e8da60a62ae0eaa Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Thu, 18 Mar 2021 14:58:18 +0100 Subject: [PATCH] bashbot.rc: fix hook status, harmonize messages for hook and poll --- bashbot.rc | 14 ++++++++------ bin/process_batch.sh | 4 ++-- modules/processUpdates.sh | 5 +++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/bashbot.rc b/bashbot.rc index e7f6f64..67026cd 100755 --- a/bashbot.rc +++ b/bashbot.rc @@ -5,7 +5,7 @@ # # tested on: ubuntu, opensuse, debian # -#### $$VERSION$$ v1.51-dev-8-gdedcc00 +#### $$VERSION$$ v1.51-dev-9-gcbd74a7 # shellcheck disable=SC2009 # shellcheck disable=SC2181 # shellcheck disable=SC2250 @@ -37,12 +37,16 @@ runas="nobody" # edit the values of the following lines to fit your config: # your bot name as given to botfather, e.g. mysomething_bot name="" +[ -z "${name}" ] && name="unknown" + # your bot installation dir -bashbotdir="/usr/local/telegram-bot-bash/telegram-bot-bash" +bashbotdir="/usr/local/telegram-bot-bash" databotdir="${bashbotdir}/data-bot-bash" +FIFO="$databotdir}/webhook-fifo-${name}" + # programs to run bashbot="cd ${bashbotdir}; ${bashbotdir}/bashbot.sh" -webhook="cd ${bashbotdir}; nohup ${bashbotdir}/bin/process_batch.sh --startbot --watch ${databotdir}/webhook-fifo-${name}" +webhook="cd ${bashbotdir}; nohup ${bashbotdir}/bin/process_batch.sh --startbot --watch ${FIFO}" # set additionl parameter, e.g. debug mode="" @@ -53,8 +57,6 @@ hooklog="WEBHOOK" # END Configuration ####################### -[ -z "${name}" ] && name="unknown" -FIFO="i${bashbotdir}/data-bot-bash/webhook-fifo-${name}" # check for bot status ps -f -u "${runas}" | grep "${name}" | grep -qF "bashbot.sh startbot" @@ -110,7 +112,7 @@ case "$1" in "poll"*) printf "bashbot (%s) is running in poll mode\n" "${name}" RETVAL=0 ;; - "webh"*) printf "bashbot (%s) is running in webhook mode\n" "${name}" + "hook"*) printf "bashbot (%s) is running in webhook mode\n" "${name}" RETVAL=0 ;; "stop"*) printf "bashbot (%s) is not running\n" "${name}" diff --git a/bin/process_batch.sh b/bin/process_batch.sh index 85d5f94..da3ac88 100755 --- a/bin/process_batch.sh +++ b/bin/process_batch.sh @@ -21,7 +21,7 @@ USAGE='process_update.sh [-h|--help] [-s|--startbot] [-w|--watch] [-n|--lines n] # AUTHOR: KayM (gnadelwartz), kay@rrr.de # CREATED: 27.02.2021 13:14 # -#### $$VERSION$$ v1.51-dev-2-g43cab46 +#### $$VERSION$$ v1.51-dev-9-gcbd74a7 #=============================================================================== #### @@ -64,7 +64,7 @@ if [ -n "${startbot}" ]; then # warn when starting bot without pipe [ -p "${file}" ] || printf "%(%c)T: %b\n" -1 "${ORANGE}Warning${NC}: File is not a pipe:${GREY} ${file##*/}${NC}" start_bot "$2" "${mode}" - printf "%(%c)T: %b\n" -1 "${GREEN}Bot start actions done, start ${mode} updates ....${NC}" + printf "%(%c)T: %b\n" -1 "${GREEN}Bot startup actions done, start ${mode} updates ...${NC}" fi # check file exist if [[ ! -r "${file}" || -d "${file}" ]]; then diff --git a/modules/processUpdates.sh b/modules/processUpdates.sh index c5286bb..7c96706 100644 --- a/modules/processUpdates.sh +++ b/modules/processUpdates.sh @@ -4,7 +4,7 @@ # File: processUpdates.sh # Note: DO NOT EDIT! this file will be overwritten on update # -#### $$VERSION$$ v1.5-0-g8adca9b +#### $$VERSION$$ v1.51-dev-9-gcbd74a7 ################################################################## ############## @@ -293,7 +293,7 @@ declare -A BASHBOTBLOCKED start_bot() { local DEBUGMSG # startup message - DEBUGMSG="Start BASHBOT updates in Mode \"${1:-normal}\" ==========" + DEBUGMSG="BASHBOT startup actions, debug mode set to \"${1:-normal}\" ==========" log_update "${DEBUGMSG}" # redirect to Debug.log if [[ "$1" == *"debug" ]]; then @@ -336,6 +336,7 @@ get_updates(){ local nextsleep="100" local stepsleep="${BASHBOT_SLEEP_STEP:-100}" local maxsleep="${BASHBOT_SLEEP:-5000}" + printf "%(%c)T: %b\n" -1 "Bot startup actions done, start polling updates ..." while true; do # adaptive sleep in ms rounded to next 0.1 s sleep "$(_round_float "${nextsleep}e-3" "1")"