always set BOTADMIN

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2021-03-03 13:27:07 +01:00
parent 53e936ee65
commit e6838d1436
4 changed files with 14 additions and 12 deletions

View File

@ -30,7 +30,7 @@ BOTCOMMANDS="-h help init start stop status suspendback resumeback killb
# 8 - curl/wget missing # 8 - curl/wget missing
# 10 - not bash! # 10 - not bash!
# #
#### $$VERSION$$ v1.45-dev-55-g5dd24c3 #### $$VERSION$$ v1.45-dev-67-g53e936e
################################################################## ##################################################################
# are we running in a terminal? # are we running in a terminal?
@ -358,7 +358,7 @@ declare -rx BOTTOKEN URL ME_URL
declare -ax CMD declare -ax CMD
declare -Ax UPD BOTSENT USER MESSAGE URLS CONTACT LOCATION CHAT FORWARD REPLYTO VENUE iQUERY iBUTTON declare -Ax UPD BOTSENT USER MESSAGE URLS CONTACT LOCATION CHAT FORWARD REPLYTO VENUE iQUERY iBUTTON
declare -Ax SERVICE NEWMEMBER LEFTMEMBER PINNED MIGRATE 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 # source the script with source as param to use functions in other scripts
# do not execute if read from other scripts # do not execute if read from other scripts
BOTADMIN="$(getConfigKey "botadmin")"
if [ -z "${SOURCE}" ]; then if [ -z "${SOURCE}" ]; then
############## ##############
# internal options only for use from bashbot and developers # internal options only for use from bashbot and developers
@ -900,7 +902,7 @@ if [ -z "${SOURCE}" ]; then
# shellcheck disable=SC2086 # shellcheck disable=SC2086
if kill ${BOTPID}; then if kill ${BOTPID}; then
# inform botadmin about stop # 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}" printf "${GREEN}OK. Bot stopped successfully.${NN}"
else else
printf "${RED}An error occurred while stopping bot.${NN}" printf "${RED}An error occurred while stopping bot.${NN}"

View File

@ -13,7 +13,7 @@
# AUTHOR: KayM (gnadelwartz), kay@rrr.de # AUTHOR: KayM (gnadelwartz), kay@rrr.de
# CREATED: 18.12.2020 12:27 # 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}/.*" FILE_REGEX="${UPLOADDIR}/.*"
# get and check ADMIN and NAME # get and check ADMIN and NAME
BOT_ADMIN="$(getConfigKey "botadmin")" # shellcheck disable=SC2153
BOT_ADMIN="${BOTADMIN}"
BOT_NAME="$(getConfigKey "botname")" BOT_NAME="$(getConfigKey "botname")"
ME="${BOT_NAME}" ME="${BOT_NAME}"
[[ -z "${BOT_ADMIN}" || "${BOT_ADMIN}" == "?" ]] && printf "%s\n" "${ORANGE}Warning: Botadmin not set, send bot command${NC} /start" [[ -z "${BOT_ADMIN}" || "${BOT_ADMIN}" == "?" ]] && printf "%s\n" "${ORANGE}Warning: Botadmin not set, send bot command${NC} /start"

View File

@ -6,7 +6,7 @@
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
# #
# shellcheck disable=SC1117,SC2059 # shellcheck disable=SC1117,SC2059
#### $$VERSION$$ v1.45-dev-48-gf4d45d8 #### $$VERSION$$ v1.45-dev-67-g53e936e
# will be automatically sourced from bashbot # will be automatically sourced from bashbot
@ -129,7 +129,7 @@ inproc() {
job_control() { job_control() {
local BOT ADM content proc CHAT job fifo killall="" local BOT ADM content proc CHAT job fifo killall=""
BOT="$(getConfigKey "botname")" BOT="$(getConfigKey "botname")"
ADM="$(getConfigKey "botadmin")" ADM="${BOTADMIN}"
debug_checks "Enter job_control" "$1" debug_checks "Enter job_control" "$1"
for FILE in "${DATADIR:-.}/"*-back.cmd; do for FILE in "${DATADIR:-.}/"*-back.cmd; do
[ "${FILE}" = "${DATADIR:-.}/*-back.cmd" ] && printf "${RED}No background processes.${NN}" && break [ "${FILE}" = "${DATADIR:-.}/*-back.cmd" ] && printf "${RED}No background processes.${NN}" && break

View File

@ -5,7 +5,7 @@
# This file is public domain in the USA and all free countries. # This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # 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 # will be automatically sourced from bashbot
@ -147,10 +147,9 @@ user_is_admin() {
# $1 user # $1 user
user_is_botadmin() { user_is_botadmin() {
[ -z "$1" ] && return 1 [ -z "$1" ] && return 1
local admin; admin="$(getConfigKey "botadmin")"; [ -z "${admin}" ] && return 1 [ -z "${BOTADMIN}" ] && return 1
[[ "${admin}" == "$1" || "${admin}" == "$2" ]] && return 0 [[ "${BOTADMIN}" == "$1" || "${BOTADMIN}" == "$2" ]] && return 0
#[[ "${admin}" = "@*" ]] && [[ "${admin}" = "$2" ]] && return 0 if [ "${BOTADMIN}" = "?" ]; then setConfigKey "botadmin" "${1:-?}"; return 0; fi
if [ "${admin}" = "?" ]; then setConfigKey "botadmin" "${1:-?}"; return 0; fi
return 1 return 1
} }