mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2024-05-11 05:55:19 +00:00
telegram-chat: act on reply from self
This commit is contained in:
BIN
doc/telegram-chat.d/03-reply.avif
Normal file
BIN
doc/telegram-chat.d/03-reply.avif
Normal file
Binary file not shown.
After Width: | Height: | Size: 49 KiB |
@ -46,6 +46,8 @@ parameters:
|
|||||||
Usage and invocation
|
Usage and invocation
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
|
### Activating device(s)
|
||||||
|
|
||||||
This script is capable of chatting with multiple devices. By default a
|
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
|
device is passive and not acting on messages. To activate it send a message
|
||||||
containing `! identity` (exclamation mark, optional space and system's
|
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
|
Send a single exclamation mark or non-existent identity to make all
|
||||||
devices passive again.
|
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.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
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
|
Known limitations
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
:local 0 "global-functions";
|
:local 0 "global-functions";
|
||||||
|
|
||||||
# expected configuration version
|
# expected configuration version
|
||||||
:global ExpectedConfigVersion 105;
|
:global ExpectedConfigVersion 106;
|
||||||
|
|
||||||
# global variables not to be changed by user
|
# global variables not to be changed by user
|
||||||
:global GlobalFunctionsReady false;
|
:global GlobalFunctionsReady false;
|
||||||
|
@ -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.";
|
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!";
|
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).";
|
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
|
# Migration steps to be applied on script updates
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
:global TelegramChatIdsTrusted;
|
:global TelegramChatIdsTrusted;
|
||||||
:global TelegramChatOffset;
|
:global TelegramChatOffset;
|
||||||
:global TelegramChatRunTime;
|
:global TelegramChatRunTime;
|
||||||
|
:global TelegramMessageIDs;
|
||||||
:global TelegramTokenId;
|
:global TelegramTokenId;
|
||||||
|
|
||||||
:global CertificateAvailable;
|
:global CertificateAvailable;
|
||||||
@ -83,7 +84,8 @@ $WaitFullyConnected;
|
|||||||
$LogPrintExit2 info $0 ("Now " . [ $IfThenElse $TelegramChatActive "active" "passive" ] . \
|
$LogPrintExit2 info $0 ("Now " . [ $IfThenElse $TelegramChatActive "active" "passive" ] . \
|
||||||
" from update " . $UpdateID . "!") false;
|
" from update " . $UpdateID . "!") false;
|
||||||
} else={
|
} 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={
|
:if ([ $ValidateSyntax ($Message->"text") ] = true) do={
|
||||||
:local State "";
|
:local State "";
|
||||||
:local File ("tmpfs/telegram-chat/" . [ $GetRandom20CharAlNum 6 ]);
|
:local File ("tmpfs/telegram-chat/" . [ $GetRandom20CharAlNum 6 ]);
|
||||||
|
Reference in New Issue
Block a user