bin: process_xxx: replace BOTADMIN with id of bot admin

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2021-02-28 14:15:26 +01:00
parent 941598d01f
commit dda86e3496
4 changed files with 10 additions and 6 deletions

View File

@ -20,7 +20,7 @@ USAGE='process_update.sh [-h|--help] -w|--watch [-n|--lines n] [file] [debug]'
# AUTHOR: KayM (gnadelwartz), kay@rrr.de # AUTHOR: KayM (gnadelwartz), kay@rrr.de
# CREATED: 27.02.2021 13:14 # CREATED: 27.02.2021 13:14
# #
#### $$VERSION$$ v1.45-dev-52-g84ff8ce #### $$VERSION$$ v1.45-dev-53-g941598d
#=============================================================================== #===============================================================================
#### ####
@ -62,9 +62,11 @@ tail ${follow} ${lines} "${file}" |\
while IFS="" read -r input while IFS="" read -r input
do do
# read json from stdin and convert update format # read json from stdin and convert update format
json='{"result": ['"${input}"']}' # replace any ID named BOTADMIN with ID of bot admin
: "${input//\"id\":BOTADMIN,/\"id\":${BOT_ADMIN},}"
json='{"result": ['"${_}"']}'
UPDATE="$(${JSONSHFILE} -b -n <<<"${json}" 2>/dev/null)" UPDATE="$(${JSONSHFILE} -b -n <<<"${json}" 2>/dev/null)"
# process telegram update # process telegram update
"${COMMAND}" "$1" "${COMMAND}" "$2"
done done

View File

@ -15,7 +15,7 @@ USAGE='process_update.sh [-h|--help] [debug] [<file]'
# AUTHOR: KayM (gnadelwartz), kay@rrr.de # AUTHOR: KayM (gnadelwartz), kay@rrr.de
# CREATED: 30.01.2021 19:14 # CREATED: 30.01.2021 19:14
# #
#### $$VERSION$$ v1.45-dev-38-g882efa8 #### $$VERSION$$ v1.45-dev-53-g941598d
#=============================================================================== #===============================================================================
#### ####
@ -31,7 +31,9 @@ print_help "${1:-nix}"
# ready, do stuff here ----- # ready, do stuff here -----
# read json from stdin and convert update format # read json from stdin and convert update format
# replace any ID named BOTADMIN with ID of bot admin
json='{"result": ['"$(cat)"']}' json='{"result": ['"$(cat)"']}'
json="${json//\"id\":BOTADMIN,/\"id\":${BOT_ADMIN},}"
UPDATE="$(${JSONSHFILE} -b -n <<<"${json}" 2>/dev/null)" UPDATE="$(${JSONSHFILE} -b -n <<<"${json}" 2>/dev/null)"
# process telegram update # process telegram update

View File

@ -25,7 +25,7 @@ USAGE='promote_user.sh [-h|--help] "CHAT[ID]" "USER[ID]" "right[:true|false]" ..
# AUTHOR: KayM (gnadelwartz), kay@rrr.de # AUTHOR: KayM (gnadelwartz), kay@rrr.de
# CREATED: 25.01.2021 22:34 # CREATED: 25.01.2021 22:34
# #
#### $$VERSION$$ v1.40-0-gf9dab50 #### $$VERSION$$ v1.45-dev-53-g941598d
#=============================================================================== #===============================================================================
#### ####

View File

@ -1 +1 @@
{"update_id":665220889,"message":{"message_id":760,"from":{"id":586928566,"is_bot":false,"first_name":"Kay","last_name":"M","username":"KayM","language_code":"de"},"chat":{"id":589682731,"first_name":"Kay","last_name":"M","username":"KayM","type":"private"},"date":1612029749,"text":"/info","entities":[{"offset":0,"length":5,"type":"bot_command"}]}} {"update_id":665220889,"message":{"message_id":760,"from":{"id":BOTADMIN,"is_bot":false,"first_name":"Kay","last_name":"M","username":"KayM","language_code":"de"},"chat":{"id":BOTADMIN,"first_name":"Kay","last_name":"M","username":"KayM","type":"private"},"date":1612029749,"text":"/info","entities":[{"offset":0,"length":5,"type":"bot_command"}]}}