aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaria Lisina <sekoohaka.sarisan@gmail.com>2025-03-27 21:48:12 +0300
committerMaria Lisina <sekoohaka.sarisan@gmail.com>2025-03-27 21:48:12 +0300
commit3c5573e81340f7986d761c76a3a25a5127a1ecdd (patch)
treecfde7a54df9dd661cde78cd3878b84d8b9e2d427
parentd002e672d3982a286133257487565ea1ea35305a (diff)
bot: Verbose bot authentication properly
Signed-off-by: Maria Lisina <sekoohaka.sarisan@gmail.com>
-rwxr-xr-xbot.sh19
1 files changed, 17 insertions, 2 deletions
diff --git a/bot.sh b/bot.sh
index d0563df..75a1f9b 100755
--- a/bot.sh
+++ b/bot.sh
@@ -322,17 +322,32 @@ curl --get \
if ! jq -e '.' "${cache}/getMe.json" > /dev/null
then
- log_text="Failed to get the bot information"
+ log_text="Failed to get bot information"
. "${units}/log.sh"
exit 1
fi
+if [ "$(jq -r '.ok' "${cache}/getMe.json")" != "true" ]
+then
+ error_description="$(jq -r '.description' "${cache}/getMe.json")"
+
+ if [ "${error_description}" != "null" ]
+ then
+ log_text="${error_description}"
+ else
+ log_text="An unknown error occurred"
+ fi
+
+ . "${units}/log.sh"
+ exit 1
+fi
+
username="$(jq -r '.result.username' "${cache}/getMe.json")"
if [ "${username}" = "null" ]
then
- log_text="Failed to authorize the bot"
+ log_text="Failed to get bot username"
. "${units}/log.sh"
exit 1