move BOTADMIN check to bashbot_env.inc

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2020-12-25 18:43:36 +01:00
parent f281ae0f6f
commit 0b7cd8ac89
5 changed files with 24 additions and 35 deletions

View File

@ -1,16 +1,19 @@
#!/bin/bash
#===============================================================================
#
# FILE: bashbor_env.inc.sh
# FILE: bashbot_env.inc.sh
#
# USAGE: source bashbot_env.inc.sh [debug]
#
# DESCRIPTION: set bashbot environment for all scripts in this directory
#
# OPTIONS: $1 - will be forwarded ro bashbot, e.g. debug
#
# LICENSE: WTFPLv2 http://www.wtfpl.net/txt/copying/
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
# CREATED: 18.12.2020 12:27
#
#### $$VERSION$$ v1.2-dev2-38-g0db0215
#### $$VERSION$$ v1.2-dev2-73-gf281ae0
#===============================================================================
# set where your bashbot lives
@ -31,3 +34,10 @@ if [ ! -r "${BASHBOT_HOME}/count.jssh" ]; then
exit 3
fi
# source bashbot and check for ADMIN
# shellcheck disable=SC1090
source "${BASHBOT_HOME}/bashbot.sh" source "$1"
ADMIN="$(getConfigKey "botadmin")"
[ "${ADMIN}" = "?" ] && echo -e "${ORANGE}Warning: Botadmin not set, did you forget to sent command${NC} /start?"

View File

@ -3,7 +3,7 @@
#
# FILE: bin/bashbot_stats.sh
#
# USAGE: bashbot_stats.sh [-h|--help]
# USAGE: bashbot_stats.sh [-h|--help] [debug]
#
# DESCRIPTION: output bashbot user stats
#
@ -16,13 +16,9 @@
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
# CREATED: 23.12.2020 20:34
#
#### $$VERSION$$ v1.2-dev2-62-gfa24673
#### $$VERSION$$ v1.2-dev2-73-gf281ae0
#===============================================================================
# set bashbot environment
# shellcheck disable=SC1090
source "${0%/*}/bashbot_env.inc.sh"
####
# parse args
case "$1" in
@ -36,9 +32,9 @@ case "$1" in
;;
esac
# source bashbot and send message
# set bashbot environment
# shellcheck disable=SC1090
source "${BASHBOT_HOME}/bashbot.sh" source "$1"
source "${0%/*}/bashbot_env.inc.sh" "$1"
####
# ready, do stuff here -----

View File

@ -24,13 +24,9 @@
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
# CREATED: 16.12.2020 16:14
#
#### $$VERSION$$ v1.2-dev2-67-g6173d77
#### $$VERSION$$ v1.2-dev2-73-gf281ae0
#===============================================================================
# set bashbot environment
# shellcheck disable=SC1090
source "${0%/*}/bashbot_env.inc.sh"
####
# broadcast is dangerous, without --doit we do a dry run ...
if [ "$1" = "--doit" ]; then
@ -79,9 +75,10 @@ case "$1" in
;;
esac
# source bashbot
# set bashbot environment
# shellcheck disable=SC1090
source "${BASHBOT_HOME}/bashbot.sh" source "$3"
source "${0%/*}/bashbot_env.inc.sh" "$2" # $3 debug
# read in users
declare -A SENDALL

View File

@ -22,7 +22,7 @@
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
# CREATED: 23.12.2020 16:52
#
#### $$VERSION$$ v1.2-dev2-72-g269cbfb
#### $$VERSION$$ v1.2-dev2-73-gf281ae0
#===============================================================================
####
@ -57,14 +57,7 @@ esac
# set bashbot environment
# shellcheck disable=SC1090
source "${0%/*}/bashbot_env.inc.sh"
# source bashbot and send message
# shellcheck disable=SC1090
source "${BASHBOT_HOME}/bashbot.sh" source "$3"
ADMIN="$(getConfigKey "botadmin")"
[ "${ADMIN}" = "?" ] && echo -e "${ORANGE}Warning: Botadmin not set, did you forget to sent command${NC} /start?"
source "${0%/*}/bashbot_env.inc.sh" "$4" # $4 debug
####
####

View File

@ -21,7 +21,7 @@
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
# CREATED: 16.12.2020 11:34
#
#### $$VERSION$$ v1.2-dev2-72-g269cbfb
#### $$VERSION$$ v1.2-dev2-73-gf281ae0
#===============================================================================
@ -56,14 +56,7 @@ esac
# set bashbot environment
# shellcheck disable=SC1090
source "${0%/*}/bashbot_env.inc.sh"
# source bashbot and send message
# shellcheck disable=SC1090
source "${BASHBOT_HOME}/bashbot.sh" source "$3"
ADMIN="$(getConfigKey "botadmin")"
[ "${ADMIN}" = "?" ] && echo -e "${ORANGE}Warning: Botadmin not set, did you forget to sent command${NC} /start?"
source "${0%/*}/bashbot_env.inc.sh" "$3" # $3 debug
####
# ready, do stuff here -----