bin: process_update.sh webhook script

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2021-01-30 20:18:54 +01:00
parent 1e49f6c2b1
commit c0f1af529e
1 changed files with 42 additions and 0 deletions

42
bin/process_update.sh Executable file
View File

@ -0,0 +1,42 @@
#!/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
#
#### $$VERSION$$ v1.40-dev-9-g1e49f6c
#===============================================================================
####
# parse args
COMMAND="process_update"
# 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
json='{"result": {"0":'"$(cat)"'}}'
UPDATE="$(${JSONSHFILE} -b -n <<<"${json}")"
# assign to bashbot ARRAY
Json2Array 'UPD' <<<"${UPDATE}"
# process telegram update
"${COMMAND}" "0" "$1"