optimize getBotName

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2020-12-03 20:43:20 +01:00
parent 59c51afb52
commit d6e1c222f7
2 changed files with 5 additions and 7 deletions

View File

@ -5,7 +5,7 @@
#
# tested on: ubuntu, opensuse, debian
#
#### $$VERSION$$ v1.2-4-g40106ee
#### $$VERSION$$ v1.2-5-g658fac6
# shellcheck disable=SC2009
# shellcheck disable=SC2181

View File

@ -11,7 +11,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.2-3-gb0281f1
#### $$VERSION$$ v1.2-6-g59c51af
#
# Exit Codes:
# - 0 success (hopefully)
@ -605,13 +605,11 @@ title2Json(){
printf '%s\n' "${title}${caption}${desc}${markup}${keyboard}"
}
# get bot name
# get bot name and id from telegram
getBotName() {
local response
declare -A BOTARRAY
response="$(getJson "$ME_URL" | "${JSONSHFILE}" -b -n 2>/dev/null)"
Json2Array 'BOTARRAY' <<<"${response}"
[[ -z "${response}" || -z "${BOTARRAY["result","username"]}" ]] && return 1
Json2Array 'BOTARRAY' <<<"$(getJson "$ME_URL" | "${JSONSHFILE}" -b -n 2>/dev/null)"
[ -z "${BOTARRAY["result","username"]}" ] && return 1
# save botname and id
setConfigKey "botname" "${BOTARRAY["result","username"]}"
setConfigKey "botid" "${BOTARRAY["result","id"]}"