add check and use of BOTADMIN in bin/ scripts

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2020-12-25 18:27:48 +01:00
parent 269cbfb1d2
commit f281ae0f6f
2 changed files with 33 additions and 14 deletions

View File

@ -8,7 +8,7 @@
# DESCRIPTION: replace a message in the given user/group
#
# OPTIONS: format - normal, markdown, html (optional)
# CHAT[ID] - ID number of CHAT
# CHAT[ID] - ID number of CHAT or BOTADMIN to send to yourself
# MESSAGE[ID] - message to replace
# message - message to send in specified format
# if no format is given send_normal_message() format is used
@ -22,13 +22,9 @@
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
# CREATED: 23.12.2020 16:52
#
#### $$VERSION$$ v1.2-dev2-62-gfa24673
#### $$VERSION$$ v1.2-dev2-72-g269cbfb
#===============================================================================
# set bashbot environment
# shellcheck disable=SC1090
source "${0%/*}/bashbot_env.inc.sh"
####
# parse args
SEND="edit_normal_message"
@ -58,15 +54,29 @@ case "$1" in
;;
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 "$4"
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?"
####
####
# ready, do stuff here -----
if [ "$1" == "BOTADMIN" ]; then
CHAT="${ADMIN}"
else
CHAT="$1"
fi
# send message in selected format
"${SEND}" "$1" "$2" "$3"
"${SEND}" "${CHAT}" "$2" "$3"
# output send message result
jssh_printDB "BOTSENT" | sort -r

View File

@ -8,7 +8,7 @@
# DESCRIPTION: send a message to the given user/group
#
# OPTIONS: format - normal, markdown, html (optional)
# CHAT[ID] - ID number of CHAT
# CHAT[ID] - ID number of CHAT or BOTADMIN to send to yourself
# message - message to send in specified format
# if no format is givern send_message() format is used
#
@ -21,12 +21,9 @@
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
# CREATED: 16.12.2020 11:34
#
#### $$VERSION$$ v1.2-dev2-62-gfa24673
#### $$VERSION$$ v1.2-dev2-72-g269cbfb
#===============================================================================
# set bashbot environment
# shellcheck disable=SC1090
source "${0%/*}/bashbot_env.inc.sh"
####
# parse args
@ -57,15 +54,27 @@ case "$1" in
;;
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?"
####
# ready, do stuff here -----
if [ "$1" == "BOTADMIN" ]; then
CHAT="${ADMIN}"
else
CHAT="$1"
fi
# send message in selected format
"${SEND}" "$1" "$2"
"${SEND}" "${CHAT}" "$2"
# output send message result
jssh_printDB "BOTSENT" | sort -r