From 62378f7cf643b154ee5e028eaa0527cb8896cffc Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Tue, 19 Jan 2021 17:24:53 +0100 Subject: [PATCH] replace old JsoenGetXxx functions with direct UPD access --- bashbot.sh | 24 ++++++++++++------------ modules/chatMember.sh | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/bashbot.sh b/bashbot.sh index e6fe4c3..1048e6b 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -30,7 +30,7 @@ BOTCOMMANDS="-h help init start stop status suspendback resumeback killb # 8 - curl/wget missing # 10 - not bash! # -#### $$VERSION$$ v1.31-dev-0-gad532cc +#### $$VERSION$$ v1.31-dev-0-gfe1fb75 ################################################################## # emmbeded system may claim bash but it is not @@ -420,7 +420,7 @@ delete_message() { get_file() { [ -z "$1" ] && return sendJson "" '"file_id": "'"$1"'"' "${URL}/getFile" - printf '%s\n' "${URL}"/"$(JsonGetString <<< "${res}" '"result","file_path"')" + printf "%s\n" "${URL}/${UPD["result","file_path"]}" } # iconv used to filter out broken utf characters, if not installed fake it @@ -660,15 +660,15 @@ JsonDecode() { printf "%b\n" "${out}${remain}" } -JsonGetString() { - sed -n -e '0,/\['"$1"'\]/ s/\['"$1"'\][ \t]"\(.*\)"$/\1/p' -} -JsonGetLine() { - sed -n -e '0,/\['"$1"'\]/ s/\['"$1"'\][ \t]//p' -} -JsonGetValue() { - sed -n -e '0,/\['"$1"'\]/ s/\['"$1"'\][ \t]\([0-9.,]*\).*/\1/p' -} +#JsonGetString() { +# sed -n -e '0,/\['"$1"'\]/ s/\['"$1"'\][ \t]"\(.*\)"$/\1/p' +#} +#JsonGetLine() { +# sed -n -e '0,/\['"$1"'\]/ s/\['"$1"'\][ \t]//p' +#} +#JsonGetValue() { +# sed -n -e '0,/\['"$1"'\]/ s/\['"$1"'\][ \t]\([0-9.,]*\).*/\1/p' +#} ################ # processing of updates starts here @@ -927,7 +927,7 @@ process_message() { CONTACT[FIRST_NAME]="$(JsonDecode "${UPD["result",${num},"message","contact","first_name"]}")" CONTACT[LAST_NAME]="$(JsonDecode "${UPD["result",${num},"message","contact","last_name"]}")" CONTACT[NUMBER]="${UPD["result",${num},"message","contact","phone_number"]}" - CONTACT[VCARD]="$(JsonGetString '"result",'"${num}"',"message","contact","vcard"' <<<"${UPDATE}")" + CONTACT[VCARD]="${UPD["result","${num}","message","contact","vcard"]}" fi # venue, must have a position diff --git a/modules/chatMember.sh b/modules/chatMember.sh index 2f9a316..091819e 100644 --- a/modules/chatMember.sh +++ b/modules/chatMember.sh @@ -5,7 +5,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v1.30-0-g3266427 +#### $$VERSION$$ v1.31-dev-0-gfe1fb75 # will be automatically sourced from bashbot @@ -76,7 +76,7 @@ leave_chat() { get_chat_member_status() { sendJson "$1" '"user_id":'"$2"'' "${URL}/getChatMember" # shellcheck disable=SC2154 - JsonGetString '"result","status"' <<< "${res}" + printf "%s\n" "${UPD["result,status"]}" } user_is_creator() {