mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-12-29 05:02:46 +00:00
enable retry by default
This commit is contained in:
parent
2bc8f398c0
commit
81c8771898
26
bashbot.sh
26
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$$ v0.96-pre-34-gf968c8b
|
||||
#### $$VERSION$$ v0.96-pre-35-g2bc8f39
|
||||
#
|
||||
# Exit Codes:
|
||||
# - 0 sucess (hopefully)
|
||||
@ -205,7 +205,7 @@ fi
|
||||
|
||||
##################
|
||||
# here we start with the real stuff
|
||||
BOTSEND_RETRY="no" # do not retry by default
|
||||
BASHBOT_RETRY="" # retry by default
|
||||
|
||||
URL="${BASHBOT_URL:-https://api.telegram.org/bot}${BOTTOKEN}"
|
||||
ME_URL=$URL'/getMe'
|
||||
@ -404,15 +404,15 @@ sendJsonResult(){
|
||||
printf "%s: RESULT=%s FUNC=%s CHAT[ID]=%s ERROR=%s DESC=%s ACTION=%s\n" "$(date)"\
|
||||
"${BOTSENT[OK]}" "${2}" "${3}" "${BOTSENT[ERROR]}" "${BOTSENT[DESCRIPTION]}" "${4:0:60}"
|
||||
# warm path, do not retry on error, also if we use wegt
|
||||
[ -n "${BOTSEND_RETRY}${BASHBOT_WGET}" ] && return
|
||||
[ -n "${BASHBOT_RETRY}${BASHBOT_WGET}" ] && return
|
||||
|
||||
# OK, we can retry sendJson, let's see what's failed
|
||||
# throttled, telegram say we send to much messages
|
||||
if [ -n "${BOTSENT[RETRY]}" ]; then
|
||||
BOTSEND_RETRY="$(( BOTSENT[RETRY]++ ))"
|
||||
printf "Retry %s in %s seconds ...\n" "${2}" "${BOTSEND_RETRY}"
|
||||
sendJsonRetry "${2}" "${BOTSEND_RETRY}" "${@:3}"
|
||||
unset BOTSEND_RETRY
|
||||
BASHBOT_RETRY="$(( BOTSENT[RETRY]++ ))"
|
||||
printf "Retry %s in %s seconds ...\n" "${2}" "${BASHBOT_RETRY}"
|
||||
sendJsonRetry "${2}" "${BASHBOT_RETRY}" "${@:3}"
|
||||
unset BASHBOT_RETRY
|
||||
return
|
||||
fi
|
||||
# timeout, failed connection or blocked
|
||||
@ -422,10 +422,10 @@ sendJsonResult(){
|
||||
printf "%s: BASHBOT IP Adress is blocked!\n" "$(date)"
|
||||
# user provided function to recover or notify block
|
||||
if _exec_if_function bashbotBlockRecover; then
|
||||
BOTSEND_RETRY="2"
|
||||
BASHBOT_RETRY="2"
|
||||
printf "bashbotBlockRecover returned true, retry %s ...\n" "${2}"
|
||||
sendJsonRetry "${2}" "${BOTSEND_RETRY}" "${@:3}"
|
||||
unset BOTSEND_RETRY
|
||||
sendJsonRetry "${2}" "${BASHBOT_RETRY}" "${@:3}"
|
||||
unset BASHBOT_RETRY
|
||||
fi
|
||||
return
|
||||
fi
|
||||
@ -433,9 +433,9 @@ sendJsonResult(){
|
||||
if [ -n "${BASHBOT_CURL_ARGS}" ] || [ "${BASHBOT_CURL}" != "curl" ]; then
|
||||
printf "Problem with \"%s %s\"? retry %s with default config ...\n"\
|
||||
"${BASHBOT_CURL}" "${BASHBOT_CURL_ARGS}" "${2}"
|
||||
BOTSEND_RETRY="2"; BASHBOT_CURL="curl"; BASHBOT_CURL_ARGS=""
|
||||
sendJsonRetry "${2}" "${BOTSEND_RETRY}" "${@:3}"
|
||||
unset BOTSEND_RETRY
|
||||
BASHBOT_RETRY="2"; BASHBOT_CURL="curl"; BASHBOT_CURL_ARGS=""
|
||||
sendJsonRetry "${2}" "${BASHBOT_RETRY}" "${@:3}"
|
||||
unset BASHBOT_RETRY
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
@ -15,7 +15,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.96-dev3-12-g3f85134
|
||||
#### $$VERSION$$ v0.96-pre-35-g2bc8f39
|
||||
#
|
||||
|
||||
# adjust your language setting here, e.g.when run from other user or cron.
|
||||
@ -38,7 +38,9 @@ It currently can send, recieve and forward messages, custom keyboards, photos, a
|
||||
#
|
||||
# this file *MUST* not edited!
|
||||
# copy "mycommands.sh.dist" to "mycommnds.sh" and change the strings there
|
||||
bashbot_help='*Available commands*:
|
||||
bashbot_help='Place your own commands and messages in mycommands.sh
|
||||
|
||||
*Available commands*:
|
||||
*• /start*: _Start bot and get this message_.
|
||||
*• /help*: _Get this message_.
|
||||
*• /info*: _Get shorter info message about this bot_.
|
||||
|
@ -8,7 +8,7 @@
|
||||
# #### if you start to develop your own bot, use the clean version of this file:
|
||||
# #### mycommands.clean
|
||||
#
|
||||
#### $$VERSION$$ v0.96-pre-13-ga71d68e
|
||||
#### $$VERSION$$ v0.96-pre-35-g2bc8f39
|
||||
#
|
||||
|
||||
# uncomment the following lines to overwrite info and help messages
|
||||
@ -29,10 +29,10 @@ export FILE_REGEX="${BASHBOT_ETC}/.*"
|
||||
# example: run bashbot over TOR
|
||||
# export BASHBOT_CURL_ARGS="--socks5-hostname 127.0.0.1:9050"
|
||||
|
||||
# unset BASHBOT_RETRY to enable retry in case of recoverable errors, e.g. throtteling
|
||||
# see logs/ERROR.log for information why send_messages etc. fail
|
||||
export BOTSEND_RETRY="no"
|
||||
#unset BOTSEND_RETRY
|
||||
# set BASHBOT_RETRY to enable retry in case of recoverable errors, e.g. throtteling
|
||||
# problems with send_,´message etc are looged to logs/ERROR.log
|
||||
unset BASHBOT_RETRY
|
||||
#export BASHBOT_RETRY="yes"
|
||||
|
||||
# set value for adaptive sleeping while waitingnfor uodates in millisconds
|
||||
# max slepp between polling updates 10s (default 5s)
|
||||
|
@ -4,7 +4,7 @@
|
||||
# files: mycommands.sh.clean
|
||||
# copy to mycommands.sh and add all your commands and functions here ...
|
||||
#
|
||||
#### $$VERSION$$ v0.96-pre-13-ga71d68e
|
||||
#### $$VERSION$$ v0.96-pre-35-g2bc8f39
|
||||
#
|
||||
|
||||
##########
|
||||
@ -27,10 +27,10 @@ export INLINE="0"
|
||||
# do NOT set to .* as this allow sending files from all locations!
|
||||
export FILE_REGEX="${BASHBOT_ETC}/.*"
|
||||
|
||||
# unset BASHBOT_RETRY to enable retry in case of recoverable errors, e.g. throtteling
|
||||
# see logs/ERROR.log for information why send_messages etc. fail
|
||||
export BOTSEND_RETRY="no"
|
||||
#unset BOTSEND_RETRY
|
||||
# set BASHBOT_RETRY to enable retry in case of recoverable errors, e.g. throtteling
|
||||
# problems with send_,´message etc are looged to logs/ERROR.log
|
||||
unset BASHBOT_RETRY
|
||||
#export BASHBOT_RETRY="yes"
|
||||
|
||||
# set value for adaptive sleeping while waitingnfor uodates in millisconds
|
||||
# max slepp between polling updates 10s (default 5s)
|
||||
|
Loading…
Reference in New Issue
Block a user