2021-01-30 19:18:54 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# shellcheck disable=SC1090,SC2034,SC2059
|
|
|
|
#===============================================================================
|
|
|
|
#
|
|
|
|
# FILE: bin/process_update.sh
|
|
|
|
#
|
|
|
|
USAGE='process_update.sh [-h|--help] [debug] [<file]'
|
|
|
|
#
|
|
|
|
# DESCRIPTION: processes ONE telegram update read from stdin, e.g. form file or webhook
|
|
|
|
#
|
|
|
|
# -h - display short help
|
|
|
|
# --help - this help
|
|
|
|
#
|
|
|
|
# LICENSE: WTFPLv2 http://www.wtfpl.net/txt/copying/
|
|
|
|
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
|
|
|
# CREATED: 30.01.2021 19:14
|
|
|
|
#
|
2021-02-28 13:15:26 +00:00
|
|
|
#### $$VERSION$$ v1.45-dev-53-g941598d
|
2021-01-30 19:18:54 +00:00
|
|
|
#===============================================================================
|
|
|
|
|
|
|
|
####
|
|
|
|
# parse args
|
2021-02-18 17:59:27 +00:00
|
|
|
COMMAND="process_multi_updates"
|
2021-01-30 19:18:54 +00:00
|
|
|
|
|
|
|
# set bashbot environment
|
|
|
|
source "${0%/*}/bashbot_env.inc.sh" "debug" # debug
|
|
|
|
print_help "${1:-nix}"
|
|
|
|
|
|
|
|
|
|
|
|
####
|
|
|
|
# ready, do stuff here -----
|
|
|
|
|
|
|
|
# read json from stdin and convert update format
|
2021-02-28 13:15:26 +00:00
|
|
|
# replace any ID named BOTADMIN with ID of bot admin
|
2021-02-01 18:37:24 +00:00
|
|
|
json='{"result": ['"$(cat)"']}'
|
2021-02-28 13:15:26 +00:00
|
|
|
json="${json//\"id\":BOTADMIN,/\"id\":${BOT_ADMIN},}"
|
2021-01-31 09:00:15 +00:00
|
|
|
UPDATE="$(${JSONSHFILE} -b -n <<<"${json}" 2>/dev/null)"
|
2021-01-30 19:18:54 +00:00
|
|
|
|
|
|
|
# process telegram update
|
2021-02-18 17:59:27 +00:00
|
|
|
"${COMMAND}" "$1"
|
2021-01-30 19:18:54 +00:00
|
|
|
|