mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2025-03-19 15:42:22 +00:00
get BOT_ADMIN and BOT_NAME in bin/bashbot_env.inc
This commit is contained in:
parent
0b7cd8ac89
commit
f016598054
@ -11,7 +11,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.2-dev2-66-gc93c9ae
|
||||
#### $$VERSION$$ v1.2-dev2-74-g0b7cd8a
|
||||
#
|
||||
# Exit Codes:
|
||||
# - 0 success (hopefully)
|
||||
|
@ -13,31 +13,46 @@
|
||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||
# CREATED: 18.12.2020 12:27
|
||||
#
|
||||
#### $$VERSION$$ v1.2-dev2-73-gf281ae0
|
||||
#### $$VERSION$$ v1.2-dev2-74-g0b7cd8a
|
||||
#===============================================================================
|
||||
|
||||
############
|
||||
# set where your bashbot lives
|
||||
# default: one dir up
|
||||
BASHBOT_HOME="$(cd "${BASH_SOURCE[0]%/*}" >/dev/null 2>&1 && pwd)/../"
|
||||
[ "${BASHBOT_HOME}" = "/../" ] && BASHBOT_HOME="../"
|
||||
|
||||
# set you own BASHBOT_HOME if different, e.g.
|
||||
# BASHBOT_HOME="/usr/local/telegram-bot-bash"
|
||||
BASHBOT_ETC="${BASHBOT_HOME}"
|
||||
BASHBOT_VAR="${BASHBOT_HOME}"
|
||||
|
||||
#####
|
||||
# if files are not readable, eviroment is wrong or bashbot is not initialized
|
||||
|
||||
# source bashbot
|
||||
if [ ! -r "${BASHBOT_HOME}/bashbot.sh" ]; then
|
||||
echo "Bashbot.sh not found in \"${BASHBOT_HOME}\""
|
||||
exit 4
|
||||
else
|
||||
# shellcheck disable=SC1090
|
||||
source "${BASHBOT_HOME}/bashbot.sh" source "$1"
|
||||
fi
|
||||
|
||||
# check for botconfig.jssh readable
|
||||
if [ ! -r "${BASHBOT_HOME}/botconfig.jssh" ]; then
|
||||
echo "Bashbot config file in \"${BASHBOT_HOME}\" does not exist or is not readable."
|
||||
if [ ! -r "${BASHBOT_ETC}/botconfig.jssh" ]; then
|
||||
echo "Bashbot config file in \"${BASHBOT_ETC}\" does not exist or is not readable."
|
||||
exit 3
|
||||
fi
|
||||
# check for count.jssh readable
|
||||
if [ ! -r "${BASHBOT_HOME}/count.jssh" ]; then
|
||||
echo "Bashbot count file in \"${BASHBOT_HOME}\" does not exist or is not readable"
|
||||
if [ ! -r "${BASHBOT_VAR}/count.jssh" ]; then
|
||||
echo "Bashbot count file in \"${BASHBOT_VAR}\" does not exist or is not readable. Did you run bashbot init?"
|
||||
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?"
|
||||
# get and check ADMIN and NAME
|
||||
BOT_ADMIN="$(getConfigKey "botadmin")"
|
||||
BOT_NAME="$(getConfigKey "botname")"
|
||||
[[ -z "${BOT_ADMIN}" || "${BOT_ADMIN}" == "?" ]] && echo -e "${ORANGE}Warning: Botadmin not set, did you forget to sent command${NC} /start"
|
||||
[[ -z "${BOT_NAME}" ]] && echo -e "${ORANGE}Warning: Botname not set, did you ever run bashbot?"
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||
# CREATED: 23.12.2020 20:34
|
||||
#
|
||||
#### $$VERSION$$ v1.2-dev2-73-gf281ae0
|
||||
#### $$VERSION$$ v1.2-dev2-74-g0b7cd8a
|
||||
#===============================================================================
|
||||
|
||||
####
|
||||
@ -39,8 +39,7 @@ source "${0%/*}/bashbot_env.inc.sh" "$1"
|
||||
####
|
||||
# ready, do stuff here -----
|
||||
|
||||
ME="$(getConfigKey "botname")"
|
||||
echo -e "${GREEN}Hi I'm ${ME}.${NC}"
|
||||
echo -e "${GREEN}Hi I'm ${BOT_NAME}.${NC}"
|
||||
declare -A STATS
|
||||
jssh_readDB_async "STATS" "${COUNTFILE}"
|
||||
for MSG in ${!STATS[*]}
|
||||
|
@ -24,7 +24,7 @@
|
||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||
# CREATED: 16.12.2020 16:14
|
||||
#
|
||||
#### $$VERSION$$ v1.2-dev2-73-gf281ae0
|
||||
#### $$VERSION$$ v1.2-dev2-74-g0b7cd8a
|
||||
#===============================================================================
|
||||
|
||||
####
|
||||
@ -88,7 +88,7 @@ if [ -z "${SENDALL[*]}" ]; then
|
||||
fi
|
||||
|
||||
# loop over users
|
||||
echo -e "${GREEN}Sending broadcast message to all users of $(getConfigKey "botname")${NC}${GREY}\c"
|
||||
echo -e "${GREEN}Sending broadcast message to all users of ${BOT_NAME}${NC}${GREY}\c"
|
||||
|
||||
{ # dry run
|
||||
[ -z "${DOIT}" ] && echo -e "${NC}\n${ORANGE}DRY RUN! use --doit as first argument to execute broadcast...${NC}"
|
||||
|
@ -22,7 +22,7 @@
|
||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||
# CREATED: 23.12.2020 16:52
|
||||
#
|
||||
#### $$VERSION$$ v1.2-dev2-73-gf281ae0
|
||||
#### $$VERSION$$ v1.2-dev2-74-g0b7cd8a
|
||||
#===============================================================================
|
||||
|
||||
####
|
||||
@ -63,7 +63,7 @@ source "${0%/*}/bashbot_env.inc.sh" "$4" # $4 debug
|
||||
####
|
||||
# ready, do stuff here -----
|
||||
if [ "$1" == "BOTADMIN" ]; then
|
||||
CHAT="${ADMIN}"
|
||||
CHAT="${BOT_ADMIN}"
|
||||
else
|
||||
CHAT="$1"
|
||||
fi
|
||||
|
@ -21,7 +21,7 @@
|
||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||
# CREATED: 16.12.2020 11:34
|
||||
#
|
||||
#### $$VERSION$$ v1.2-dev2-73-gf281ae0
|
||||
#### $$VERSION$$ v1.2-dev2-74-g0b7cd8a
|
||||
#===============================================================================
|
||||
|
||||
|
||||
@ -61,7 +61,7 @@ source "${0%/*}/bashbot_env.inc.sh" "$3" # $3 debug
|
||||
####
|
||||
# ready, do stuff here -----
|
||||
if [ "$1" == "BOTADMIN" ]; then
|
||||
CHAT="${ADMIN}"
|
||||
CHAT="${BOT_ADMIN}"
|
||||
else
|
||||
CHAT="$1"
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user