mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2024-05-11 05:55:19 +00:00
telegram-chat: rework the retry logic
... with increasing delay.
This commit is contained in:
@@ -48,15 +48,17 @@ $WaitFullyConnected;
|
||||
}
|
||||
|
||||
:local Data false;
|
||||
:for I from=2 to=0 do={
|
||||
:for I from=1 to=4 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 ($I < 4) do={
|
||||
$LogPrintExit2 debug $0 ("Fetch failed, " . $I . ". try.") false;
|
||||
:delay (($I * $I) "s");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user