From f281ae0f6fc2b2cb6582348ba667e2a941b58e55 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Fri, 25 Dec 2020 18:27:48 +0100 Subject: [PATCH] add check and use of BOTADMIN in bin/ scripts --- bin/send_edit_message.sh | 26 ++++++++++++++++++-------- bin/send_message.sh | 21 +++++++++++++++------ 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/bin/send_edit_message.sh b/bin/send_edit_message.sh index f7935ca..3354b77 100755 --- a/bin/send_edit_message.sh +++ b/bin/send_edit_message.sh @@ -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 diff --git a/bin/send_message.sh b/bin/send_message.sh index 5d90d6d..8416e39 100755 --- a/bin/send_message.sh +++ b/bin/send_message.sh @@ -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