mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-11-22 23:45:10 +00:00
optimize getBotName
This commit is contained in:
parent
59c51afb52
commit
d6e1c222f7
@ -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
|
||||
|
||||
|
10
bashbot.sh
10
bashbot.sh
@ -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"]}"
|
||||
|
Loading…
Reference in New Issue
Block a user