aboutsummaryrefslogtreecommitdiffstats
path: root/telegram-chat
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2023-02-23 22:36:37 +0100
committerGravatar Christian Hesse <mail@eworm.de>2023-02-26 22:19:36 +0100
commit02b447212d3b6aa238c719b34a8b245d63ca5deb (patch)
treee6f57af5285c2a3ea45977dcc891a736e1cad878 /telegram-chat
parent5ea892662f94d817ff325abe21620665efde24fa (diff)
telegram-chat: ignore new messages after reboot
This script supports multiple devices, and sending offset to discard messages is delayed to third fetch to make sure all devices get the message. This can cause trouble, though: Sending a device a reboot command can make that device reboot multiple times 🥴 or - even worse - make it enter an infinite boot loop 😳 if it is the only device. So let's ignore first messages after reboot.
Diffstat (limited to 'telegram-chat')
-rw-r--r--telegram-chat3
1 files changed, 2 insertions, 1 deletions
diff --git a/telegram-chat b/telegram-chat
index 8b7fa5f..e4bd783 100644
--- a/telegram-chat
+++ b/telegram-chat
@@ -74,7 +74,8 @@ $WaitFullyConnected;
:local UpdateID 0;
:foreach Update in=[ :toarray $Data ] do={
:set UpdateID [ $JsonGetKey $Update "update_id" ];
- :if ($UpdateID >= $TelegramChatOffset->2) do={
+ :if (($TelegramChatOffset->0 > 0 || [ /system/resource/get uptime ] > 5m) && \
+ $UpdateID >= $TelegramChatOffset->2) do={
:local Trusted false;
:local Message [ $JsonGetKey $Update "message" ];
:local MessageId [ $JsonGetKey $Message "message_id" ];