diff options
author | Christian Hesse <mail@eworm.de> | 2023-10-10 13:16:58 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2023-10-16 13:11:20 +0200 |
commit | 399d952ac21057c5ab88120bef4a400b06caea3b (patch) | |
tree | 1c2b9317e0b4223b30409d142827455ca34cc53f | |
parent | fd1263324dbbb0e80bc99e30d317eca9fd7b264b (diff) |
telegram-chat: act on reply from selfchange-106-1
-rw-r--r-- | doc/telegram-chat.d/03-reply.avif | bin | 0 -> 50126 bytes | |||
-rw-r--r-- | doc/telegram-chat.md | 15 | ||||
-rw-r--r-- | global-functions.rsc | 2 | ||||
-rw-r--r-- | news-and-changes.rsc | 1 | ||||
-rw-r--r-- | telegram-chat.rsc | 4 |
5 files changed, 20 insertions, 2 deletions
diff --git a/doc/telegram-chat.d/03-reply.avif b/doc/telegram-chat.d/03-reply.avif Binary files differnew file mode 100644 index 0000000..515853e --- /dev/null +++ b/doc/telegram-chat.d/03-reply.avif diff --git a/doc/telegram-chat.md b/doc/telegram-chat.md index 391042d..3cbc710 100644 --- a/doc/telegram-chat.md +++ b/doc/telegram-chat.md @@ -46,6 +46,8 @@ parameters: Usage and invocation -------------------- +### Activating device(s) + This script is capable of chatting with multiple devices. By default a device is passive and not acting on messages. To activate it send a message containing `! identity` (exclamation mark, optional space and system's @@ -63,6 +65,19 @@ act on your commands. Send a single exclamation mark or non-existent identity to make all devices passive again. +### Reply to message + +Let's assume you received a message from a device before, and want to send +a command to that device. No need to activate it, you can just reply to +that message. + +![reply to message](telegram-chat.d/03-reply.avif) + +Associated messages are cleared on device reboot. + +> ⚠️ **Warning**: If another device is activated both will act, the one from +> reply and the active one! + Known limitations ----------------- diff --git a/global-functions.rsc b/global-functions.rsc index df374b8..dbedfbc 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -12,7 +12,7 @@ :local 0 "global-functions"; # expected configuration version -:global ExpectedConfigVersion 105; +:global ExpectedConfigVersion 106; # global variables not to be changed by user :global GlobalFunctionsReady false; diff --git a/news-and-changes.rsc b/news-and-changes.rsc index b027fb6..bbbaad6 100644 --- a/news-and-changes.rsc +++ b/news-and-changes.rsc @@ -19,6 +19,7 @@ 103="Dropped hard-coded name and timeout from 'hotspot-to-wpa-cleanup', instead a comment is required for dhcp server now."; 104="All relevant scripts were ported to new wifiwave2 and are available for AX devices now!"; 105="Extended 'check-routeros-update' to support automatic update from specific neighbor(s)."; + 106="Modified 'telegram-chat' to make it act on message replies, without activation."; }; # Migration steps to be applied on script updates diff --git a/telegram-chat.rsc b/telegram-chat.rsc index 6083fee..29130db 100644 --- a/telegram-chat.rsc +++ b/telegram-chat.rsc @@ -17,6 +17,7 @@ :global TelegramChatIdsTrusted; :global TelegramChatOffset; :global TelegramChatRunTime; +:global TelegramMessageIDs; :global TelegramTokenId; :global CertificateAvailable; @@ -83,7 +84,8 @@ $WaitFullyConnected; $LogPrintExit2 info $0 ("Now " . [ $IfThenElse $TelegramChatActive "active" "passive" ] . \ " from update " . $UpdateID . "!") false; } else={ - :if ($TelegramChatActive = true && [ :len ($Message->"text") ] > 0) do={ + :if (($TelegramMessageIDs->([ $ParseJson ($Message->"reply_to_message") ]->"message_id") = 1 || \ + $TelegramChatActive = true) && [ :len ($Message->"text") ] > 0) do={ :if ([ $ValidateSyntax ($Message->"text") ] = true) do={ :local State ""; :local File ("tmpfs/telegram-chat/" . [ $GetRandom20CharAlNum 6 ]); |