diff --git a/bashbot.sh b/bashbot.sh index 8165f03..182cdbc 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -30,7 +30,7 @@ BOTCOMMANDS="-h help init start stop status suspendback resumeback killb # 8 - curl/wget missing # 10 - not bash! # -#### $$VERSION$$ v1.45-dev-55-g5dd24c3 +#### $$VERSION$$ v1.45-dev-67-g53e936e ################################################################## # are we running in a terminal? @@ -358,7 +358,7 @@ declare -rx BOTTOKEN URL ME_URL declare -ax CMD declare -Ax UPD BOTSENT USER MESSAGE URLS CONTACT LOCATION CHAT FORWARD REPLYTO VENUE iQUERY iBUTTON declare -Ax SERVICE NEWMEMBER LEFTMEMBER PINNED MIGRATE -export res CAPTION ME +export res CAPTION ME BOTADMIN ############### @@ -788,6 +788,8 @@ fi # source the script with source as param to use functions in other scripts # do not execute if read from other scripts +BOTADMIN="$(getConfigKey "botadmin")" + if [ -z "${SOURCE}" ]; then ############## # internal options only for use from bashbot and developers @@ -900,7 +902,7 @@ if [ -z "${SOURCE}" ]; then # shellcheck disable=SC2086 if kill ${BOTPID}; then # inform botadmin about stop - send_normal_message "$(getConfigKey "botadmin")" "Bot ${ME} stopped ..." & + send_normal_message "${BOTADMIN}" "Bot ${ME} stopped ..." & printf "${GREEN}OK. Bot stopped successfully.${NN}" else printf "${RED}An error occurred while stopping bot.${NN}" diff --git a/bin/bashbot_env.inc.sh b/bin/bashbot_env.inc.sh index f7524ac..d4b43b9 100644 --- a/bin/bashbot_env.inc.sh +++ b/bin/bashbot_env.inc.sh @@ -13,7 +13,7 @@ # AUTHOR: KayM (gnadelwartz), kay@rrr.de # CREATED: 18.12.2020 12:27 # -#### $$VERSION$$ v1.45-dev-50-g34923dd +#### $$VERSION$$ v1.45-dev-67-g53e936e #=============================================================================== ############ @@ -59,7 +59,8 @@ UPLOADDIR="${BASHBOT_VAR%/bin*}" FILE_REGEX="${UPLOADDIR}/.*" # get and check ADMIN and NAME -BOT_ADMIN="$(getConfigKey "botadmin")" +# shellcheck disable=SC2153 +BOT_ADMIN="${BOTADMIN}" BOT_NAME="$(getConfigKey "botname")" ME="${BOT_NAME}" [[ -z "${BOT_ADMIN}" || "${BOT_ADMIN}" == "?" ]] && printf "%s\n" "${ORANGE}Warning: Botadmin not set, send bot command${NC} /start" diff --git a/modules/background.sh b/modules/background.sh index c5720be..44b655c 100644 --- a/modules/background.sh +++ b/modules/background.sh @@ -6,7 +6,7 @@ # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # # shellcheck disable=SC1117,SC2059 -#### $$VERSION$$ v1.45-dev-48-gf4d45d8 +#### $$VERSION$$ v1.45-dev-67-g53e936e # will be automatically sourced from bashbot @@ -129,7 +129,7 @@ inproc() { job_control() { local BOT ADM content proc CHAT job fifo killall="" BOT="$(getConfigKey "botname")" - ADM="$(getConfigKey "botadmin")" + ADM="${BOTADMIN}" debug_checks "Enter job_control" "$1" for FILE in "${DATADIR:-.}/"*-back.cmd; do [ "${FILE}" = "${DATADIR:-.}/*-back.cmd" ] && printf "${RED}No background processes.${NN}" && break diff --git a/modules/chatMember.sh b/modules/chatMember.sh index 54462c6..53c6ffa 100644 --- a/modules/chatMember.sh +++ b/modules/chatMember.sh @@ -5,7 +5,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v1.45-dev-25-gb1f6a0b +#### $$VERSION$$ v1.45-dev-67-g53e936e # will be automatically sourced from bashbot @@ -147,10 +147,9 @@ user_is_admin() { # $1 user user_is_botadmin() { [ -z "$1" ] && return 1 - local admin; admin="$(getConfigKey "botadmin")"; [ -z "${admin}" ] && return 1 - [[ "${admin}" == "$1" || "${admin}" == "$2" ]] && return 0 - #[[ "${admin}" = "@*" ]] && [[ "${admin}" = "$2" ]] && return 0 - if [ "${admin}" = "?" ]; then setConfigKey "botadmin" "${1:-?}"; return 0; fi + [ -z "${BOTADMIN}" ] && return 1 + [[ "${BOTADMIN}" == "$1" || "${BOTADMIN}" == "$2" ]] && return 0 + if [ "${BOTADMIN}" = "?" ]; then setConfigKey "botadmin" "${1:-?}"; return 0; fi return 1 }