Skip to content

Commit dded2ae

Browse files
author
Juliano Santos
committed
Verificação de conexão com a core do Telegram.
1 parent 8fdb767 commit dded2ae

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

ShellBot.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,9 @@ ShellBot.init()
616616
declare -gr _TOKEN_=$token # TOKEN
617617
declare -gr _API_TELEGRAM_="https://api.telegram.org/bot$_TOKEN_" # API
618618

619+
# Testa conexão.
620+
curl -s "$_API_TELEGRAM_" &>- || MessageError API 'não foi possível estabelecer conexão com o Telegram.'
621+
619622
# Um método simples para testar o token de autenticação do seu bot.
620623
# Não requer parâmetros. Retorna informações básicas sobre o bot em forma de um objeto Usuário.
621624
ShellBot.getMe()
@@ -629,7 +632,7 @@ ShellBot.init()
629632
return $?
630633
}
631634

632-
ShellBot.getMe &>/dev/null || MessageError API "$_ERR_TOKEN_UNAUTHORIZED_" '[-t, --token]'
635+
ShellBot.getMe &>- || MessageError API "$_ERR_TOKEN_UNAUTHORIZED_" '[-t, --token]'
633636

634637
# Salva as informações do bot.
635638
declare -gr _BOT_INFO_=(
@@ -5693,7 +5696,7 @@ _EOF
56935696
ShellBot.sendChatAction --chat_id $u_message_chat_id --action ${_BOT_RULES_[$i:bot_action]} &>/dev/null
56945697
fi
56955698
done
5696-
${_BOT_RULES_[$i:continue]:-return 0}
5699+
[[ ${_BOT_RULES_[$i:continue]} ]] || return 0
56975700
done
56985701

56995702
return 1

0 commit comments

Comments
 (0)