fix BASHBOT_RETRY, add example it bot is blocked

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2020-07-12 11:19:58 +02:00
parent 2b104716df
commit ef4d21f6f4
2 changed files with 12 additions and 4 deletions

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$$ v0.981-0-g3552876
#### $$VERSION$$ v0.99-dev2-0-g2b10471
#
# Exit Codes:
# - 0 success (hopefully)
@ -496,7 +496,7 @@ sendJsonResult(){
# OK, we can retry sendJson, let's see what's failed
# throttled, telegram say we send to much messages
if [ -n "${BOTSENT[RETRY]}" ]; then
BASHBOT_RETRY="$(( BOTSENT[RETRY]++ ))"
BASHBOT_RETRY="$(( ++BOTSENT[RETRY] ))"
printf "Retry %s in %s seconds ...\n" "${2}" "${BASHBOT_RETRY}"
sendJsonRetry "${2}" "${BASHBOT_RETRY}" "${@:3}"
unset BASHBOT_RETRY
@ -506,7 +506,7 @@ sendJsonResult(){
if [ "${BOTSENT[ERROR]}" == "999" ];then
# check if default curl and args are OK
if ! curl -sL -k -m 2 "${URL}" >/dev/null 2>&1 ; then
printf "%s: BASHBOT IP Address is blocked!\n" "$(date)"
printf "%s: BASHBOT IP Address seems blocked!\n" "$(date)"
# user provided function to recover or notify block
if _exec_if_function bashbotBlockRecover; then
BASHBOT_RETRY="2"

View File

@ -8,7 +8,7 @@
# #### if you start to develop your own bot, use the clean version of this file:
# #### mycommands.clean
#
#### $$VERSION$$ v0.98-2-g2d48670
#### $$VERSION$$ v0.99-dev2-0-g2b10471
#
# uncomment the following lines to overwrite info and help messages
@ -248,6 +248,14 @@ else
[ -f ".jssh" ] && printf "%s: %s\n" "${1}" "Ups, found file \"${PWD:-.}/.jssh\"! =========="
}
# called when bashbot sedn command failed because we can not connect to telegram
# return 0 to retry, return non 0 to give up
bashbotBlockRecover() {
# place your commnds to unblock here, e.g. change IP or simply wait
sleep 60 && return 0 # may be temporary
return 1
}
# place your processing functions here
# $1 search parameter