bashbot.rc: fix hook status, harmonize messages for hook and poll

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2021-03-18 14:58:18 +01:00
parent cbd74a7f72
commit 12157b380d
3 changed files with 13 additions and 10 deletions

View File

@ -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}"

View File

@ -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

View File

@ -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")"