aboutsummaryrefslogtreecommitdiffstats
path: root/telegram-chat.rsc
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2023-10-17 21:22:51 +0200
committerGravatar Christian Hesse <mail@eworm.de>2023-10-17 21:37:13 +0200
commitfffe0a3b502fa43c3b836264bd1a7ca63f5b8aaa (patch)
tree55433a1c8b3282039d0a368a14253ea0810ca2be /telegram-chat.rsc
parentab44377fb6d01a2b7ccfab71ebf68b9306bc4df7 (diff)
telegram-chat: retry on fetch failure...
... and exit with a warning.
Diffstat (limited to 'telegram-chat.rsc')
-rw-r--r--telegram-chat.rsc23
1 files changed, 16 insertions, 7 deletions
diff --git a/telegram-chat.rsc b/telegram-chat.rsc
index c17394a..7486276 100644
--- a/telegram-chat.rsc
+++ b/telegram-chat.rsc
@@ -47,13 +47,22 @@ $WaitFullyConnected;
$LogPrintExit2 warning $0 ("Downloading required certificate failed.") true;
}
-:local Data;
-:do {
- :set Data ([ /tool/fetch check-certificate=yes-without-crl output=user \
- ("https://api.telegram.org/bot" . $TelegramTokenId . "/getUpdates?offset=" . \
- $TelegramChatOffset->0 . "&allowed_updates=%5B%22message%22%5D") as-value ]->"data");
-} on-error={
- $LogPrintExit2 debug $0 ("Failed getting updates from Telegram.") true;
+:local Data false;
+:for I from=2 to=0 do={
+ :if ($Data = false) do={
+ :do {
+ :set Data ([ /tool/fetch check-certificate=yes-without-crl output=user \
+ ("https://api.telegram.org/bot" . $TelegramTokenId . "/getUpdates?offset=" . \
+ $TelegramChatOffset->0 . "&allowed_updates=%5B%22message%22%5D") as-value ]->"data");
+ } on-error={
+ $LogPrintExit2 debug $0 ("Fetch failed, " . $I . " retries pending.") false;
+ :delay 2s;
+ }
+ }
+}
+
+:if ($Data = false) do={
+ $LogPrintExit2 warning $0 ("Failed getting updates from Telegram.") true;
}
:local UpdateID 0;