mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-06-04 19:30:52 +00:00
fix BASHBOT_RETRY, add example it bot is blocked
This commit is contained in:
parent
2b104716df
commit
ef4d21f6f4
|
@ -11,7 +11,7 @@
|
||||||
# This file is public domain in the USA and all free countries.
|
# This file is public domain in the USA and all free countries.
|
||||||
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
||||||
#
|
#
|
||||||
#### $$VERSION$$ v0.981-0-g3552876
|
#### $$VERSION$$ v0.99-dev2-0-g2b10471
|
||||||
#
|
#
|
||||||
# Exit Codes:
|
# Exit Codes:
|
||||||
# - 0 success (hopefully)
|
# - 0 success (hopefully)
|
||||||
|
@ -496,7 +496,7 @@ sendJsonResult(){
|
||||||
# OK, we can retry sendJson, let's see what's failed
|
# OK, we can retry sendJson, let's see what's failed
|
||||||
# throttled, telegram say we send to much messages
|
# throttled, telegram say we send to much messages
|
||||||
if [ -n "${BOTSENT[RETRY]}" ]; then
|
if [ -n "${BOTSENT[RETRY]}" ]; then
|
||||||
BASHBOT_RETRY="$(( BOTSENT[RETRY]++ ))"
|
BASHBOT_RETRY="$(( ++BOTSENT[RETRY] ))"
|
||||||
printf "Retry %s in %s seconds ...\n" "${2}" "${BASHBOT_RETRY}"
|
printf "Retry %s in %s seconds ...\n" "${2}" "${BASHBOT_RETRY}"
|
||||||
sendJsonRetry "${2}" "${BASHBOT_RETRY}" "${@:3}"
|
sendJsonRetry "${2}" "${BASHBOT_RETRY}" "${@:3}"
|
||||||
unset BASHBOT_RETRY
|
unset BASHBOT_RETRY
|
||||||
|
@ -506,7 +506,7 @@ sendJsonResult(){
|
||||||
if [ "${BOTSENT[ERROR]}" == "999" ];then
|
if [ "${BOTSENT[ERROR]}" == "999" ];then
|
||||||
# check if default curl and args are OK
|
# check if default curl and args are OK
|
||||||
if ! curl -sL -k -m 2 "${URL}" >/dev/null 2>&1 ; then
|
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
|
# user provided function to recover or notify block
|
||||||
if _exec_if_function bashbotBlockRecover; then
|
if _exec_if_function bashbotBlockRecover; then
|
||||||
BASHBOT_RETRY="2"
|
BASHBOT_RETRY="2"
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
# #### if you start to develop your own bot, use the clean version of this file:
|
# #### if you start to develop your own bot, use the clean version of this file:
|
||||||
# #### mycommands.clean
|
# #### mycommands.clean
|
||||||
#
|
#
|
||||||
#### $$VERSION$$ v0.98-2-g2d48670
|
#### $$VERSION$$ v0.99-dev2-0-g2b10471
|
||||||
#
|
#
|
||||||
|
|
||||||
# uncomment the following lines to overwrite info and help messages
|
# 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\"! =========="
|
[ -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
|
# place your processing functions here
|
||||||
|
|
||||||
# $1 search parameter
|
# $1 search parameter
|
||||||
|
|
Loading…
Reference in New Issue
Block a user