fix no need for JsonDecode

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2020-12-13 10:24:26 +01:00
parent cdb63b8c76
commit 22741d9a0c

View File

@ -11,7 +11,7 @@
# This file is public domain in the USA and all free countries. # This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
# #
#### $$VERSION$$ v1.2-dev2-2-g401a31a #### $$VERSION$$ v1.2-dev2-3-gcdb63b8
# #
# Exit Codes: # Exit Codes:
# - 0 success (hopefully) # - 0 success (hopefully)
@ -926,6 +926,7 @@ process_message() {
# service messages, group or channel only! # service messages, group or channel only!
if [[ "${CHAT[ID]}" == "-"* ]] ; then if [[ "${CHAT[ID]}" == "-"* ]] ; then
# new chat member
if [ -n "${UPD["result",${num},"message","new_chat_member","id"]}" ]; then if [ -n "${UPD["result",${num},"message","new_chat_member","id"]}" ]; then
SERVICE[NEWMEMBER]="${UPD["result",${num},"message","new_chat_member","id"]}" SERVICE[NEWMEMBER]="${UPD["result",${num},"message","new_chat_member","id"]}"
NEWMEMBER[ID]="${SERVICE[NEWMEMBER]}" NEWMEMBER[ID]="${SERVICE[NEWMEMBER]}"
@ -936,6 +937,7 @@ process_message() {
[ -z "${MESSAGE[0]}" ] &&\ [ -z "${MESSAGE[0]}" ] &&\
MESSAGE[0]="/_new_chat_member ${NEWMEMBER[ID]} ${NEWMEMBER[USERNAME]:=${NEWMEMBER[FIRST_NAME]} ${NEWMEMBER[LAST_NAME]}}" MESSAGE[0]="/_new_chat_member ${NEWMEMBER[ID]} ${NEWMEMBER[USERNAME]:=${NEWMEMBER[FIRST_NAME]} ${NEWMEMBER[LAST_NAME]}}"
fi fi
# left chat member
if [ -n "${UPD["result",${num},"message","left_chat_member","id"]}" ]; then if [ -n "${UPD["result",${num},"message","left_chat_member","id"]}" ]; then
SERVICE[LEFTMEMBER]="${UPD["result",${num},"message","left_chat_member","id"]}" SERVICE[LEFTMEMBER]="${UPD["result",${num},"message","left_chat_member","id"]}"
LEFTMEMBER[ID]="${SERVICE[LEFTMEBER]}" LEFTMEMBER[ID]="${SERVICE[LEFTMEBER]}"
@ -946,7 +948,7 @@ process_message() {
[ -z "${MESSAGE[0]}" ] &&\ [ -z "${MESSAGE[0]}" ] &&\
MESSAGE[0]="/_left_chat_member ${LEFTMEMBER[ID]} ${LEFTMEMBER[USERNAME]:=${LEFTMEMBER[FIRST_NAME]} ${LEFTMEMBER[LAST_NAME]}}" MESSAGE[0]="/_left_chat_member ${LEFTMEMBER[ID]} ${LEFTMEMBER[USERNAME]:=${LEFTMEMBER[FIRST_NAME]} ${LEFTMEMBER[LAST_NAME]}}"
fi fi
# check for any of them! # chat title / photo, check for any of them!
if grep -qs -e '\["result",'"${num}"',"message","new_chat_[tp]' <<<"${UPDATE}"; then if grep -qs -e '\["result",'"${num}"',"message","new_chat_[tp]' <<<"${UPDATE}"; then
SERVICE[NEWTITLE]="$(JsonDecode "${UPD["result",${num},"message","new_chat_title"]}")" SERVICE[NEWTITLE]="$(JsonDecode "${UPD["result",${num},"message","new_chat_title"]}")"
[ -z "${MESSAGE[0]}" ] && [ -n "${SERVICE[NEWTITLE]}" ] &&\ [ -z "${MESSAGE[0]}" ] && [ -n "${SERVICE[NEWTITLE]}" ] &&\
@ -955,7 +957,8 @@ process_message() {
[ -z "${MESSAGE[0]}" ] && [ -n "${SERVICE[NEWPHOTO]}" ] &&\ [ -z "${MESSAGE[0]}" ] && [ -n "${SERVICE[NEWPHOTO]}" ] &&\
MESSAGE[0]="/_new_chat_photo ${USER[ID]} ${SERVICE[NEWPHOTO]}" MESSAGE[0]="/_new_chat_photo ${USER[ID]} ${SERVICE[NEWPHOTO]}"
fi fi
if [ -n "$(JsonDecode "${UPD["result",${num},"message","pinned_message","message_id"]}")" ]; then # pinned message
if [ -n "${UPD["result",${num},"message","pinned_message","message_id"]}" ]; then
SERVICE[PINNED]="$(JsonDecode "${UPD["result",${num},"message","pinned_message","message_id"]}")" SERVICE[PINNED]="$(JsonDecode "${UPD["result",${num},"message","pinned_message","message_id"]}")"
PINNED[ID]="${SERVICE[PINNED]}" PINNED[ID]="${SERVICE[PINNED]}"
PINNED[MESSAGE]="$(JsonDecode "${UPD["result",${num},"message","pinned_message","text"]}")" PINNED[MESSAGE]="$(JsonDecode "${UPD["result",${num},"message","pinned_message","text"]}")"