bashbot: use Json2Array UPD for response also
This commit is contained in:
parent
277178389a
commit
ef972c5714
18
bashbot.sh
18
bashbot.sh
|
@ -30,7 +30,7 @@ BOTCOMMANDS="-h help init start stop status suspendback resumeback killb
|
||||||
# 8 - curl/wget missing
|
# 8 - curl/wget missing
|
||||||
# 10 - not bash!
|
# 10 - not bash!
|
||||||
#
|
#
|
||||||
#### $$VERSION$$ v1.30-dev-23-g0f27e71
|
#### $$VERSION$$ v1.30-dev-24-g2771783
|
||||||
##################################################################
|
##################################################################
|
||||||
|
|
||||||
# emmbeded system may claim bash but it is not
|
# emmbeded system may claim bash but it is not
|
||||||
|
@ -555,21 +555,21 @@ sendJsonRetry(){
|
||||||
sendJsonResult(){
|
sendJsonResult(){
|
||||||
local offset=0
|
local offset=0
|
||||||
BOTSENT=( )
|
BOTSENT=( )
|
||||||
|
Json2Array 'UPD' <<<"$1"
|
||||||
[ -n "${BASHBOTDEBUG}" ] && log_message "New Result ==========\n$1"
|
[ -n "${BASHBOTDEBUG}" ] && log_message "New Result ==========\n$1"
|
||||||
BOTSENT[OK]="$(JsonGetLine '"ok"' <<< "$1")"
|
BOTSENT[OK]="${UPD["ok"]}"
|
||||||
if [ "${BOTSENT[OK]}" = "true" ]; then
|
if [ "${BOTSENT[OK]}" = "true" ]; then
|
||||||
BOTSENT[RESULT]="$(JsonGetString '"result"' <<< "$1")"
|
BOTSENT[ID]="${UPD["result","message_id"]}"
|
||||||
BOTSENT[ID]="$(JsonGetValue '"result","message_id"' <<< "$1")"
|
BOTSENT[CHAT]="${UPD["result","chat","id"]}"
|
||||||
BOTSENT[CHAT]="$(JsonGetValue '"result","chat","id"' <<< "$1")"
|
[ -n "${UPD["result"]}" ] && BOTSENT[RESULT]="${UPD["result"]}"
|
||||||
return
|
return
|
||||||
# hot path everything OK!
|
# hot path everything OK!
|
||||||
else
|
else
|
||||||
# oops something went wrong!
|
# oops something went wrong!
|
||||||
if [ -n "$1" ]; then
|
if [ -n "$1" ]; then
|
||||||
BOTSENT[ERROR]="$(JsonGetValue '"error_code"' <<< "$1")"
|
BOTSENT[ERROR]="${UPD["error_code"]}"
|
||||||
BOTSENT[DESCRIPTION]="$(JsonGetString '"description"' <<< "$1")"
|
BOTSENT[DESCRIPTION]="${UPD["description"]}"
|
||||||
grep -qs -F '"parameters","retry_after"' <<< "$1" &&\
|
[ -n "${UPD["parameters","retry_after"]}" ] && BOTSENT[RETRY]="${UPD["parameters","retry_after"]}"
|
||||||
BOTSENT[RETRY]="$(JsonGetValue '"parameters","retry_after"' <<< "$1")"
|
|
||||||
else
|
else
|
||||||
BOTSENT[OK]="false"
|
BOTSENT[OK]="false"
|
||||||
BOTSENT[ERROR]="999"
|
BOTSENT[ERROR]="999"
|
||||||
|
|
Loading…
Reference in New Issue