mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-06-27 20:08:54 +02:00
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.
This commit is contained in:
parent
5ea892662f
commit
02b447212d
1 changed files with 2 additions and 1 deletions
|
@ -74,7 +74,8 @@ $WaitFullyConnected;
|
||||||
:local UpdateID 0;
|
:local UpdateID 0;
|
||||||
:foreach Update in=[ :toarray $Data ] do={
|
:foreach Update in=[ :toarray $Data ] do={
|
||||||
:set UpdateID [ $JsonGetKey $Update "update_id" ];
|
: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 Trusted false;
|
||||||
:local Message [ $JsonGetKey $Update "message" ];
|
:local Message [ $JsonGetKey $Update "message" ];
|
||||||
:local MessageId [ $JsonGetKey $Message "message_id" ];
|
:local MessageId [ $JsonGetKey $Message "message_id" ];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue