mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
telegram-chat: always reply to origin chat
This commit is contained in:
parent
2cb74f0269
commit
08383daa5c
2 changed files with 4 additions and 3 deletions
|
@ -105,7 +105,7 @@ it to receive messages you have to make it an admin of that group! It is
|
||||||
fine to deny all permissions, though.
|
fine to deny all permissions, though.
|
||||||
|
|
||||||
Also adding an admin to a group can cause the group id to change, so check
|
Also adding an admin to a group can cause the group id to change, so check
|
||||||
that if things break suddenly.
|
that if notifications break suddenly.
|
||||||
|
|
||||||
See also
|
See also
|
||||||
--------
|
--------
|
||||||
|
|
|
@ -78,6 +78,7 @@ $WaitFullyConnected;
|
||||||
:local From [ $JsonGetKey $Message "from" ];
|
:local From [ $JsonGetKey $Message "from" ];
|
||||||
:local FromID [ $JsonGetKey $From "id" ];
|
:local FromID [ $JsonGetKey $From "id" ];
|
||||||
:local FromUserName [ $JsonGetKey $From "username" ];
|
:local FromUserName [ $JsonGetKey $From "username" ];
|
||||||
|
:local ChatID [ $JsonGetKey [ $JsonGetKey $Message "chat" ] "id" ];
|
||||||
:foreach IdsTrusted in=($TelegramChatId, $TelegramChatIdsTrusted) do={
|
:foreach IdsTrusted in=($TelegramChatId, $TelegramChatIdsTrusted) do={
|
||||||
:if ($FromID = $IdsTrusted || $FromUserName = $IdsTrusted) do={
|
:if ($FromID = $IdsTrusted || $FromUserName = $IdsTrusted) do={
|
||||||
:set Trusted true;
|
:set Trusted true;
|
||||||
|
@ -109,13 +110,13 @@ $WaitFullyConnected;
|
||||||
:set State "The command failed with an error!\n\n";
|
:set State "The command failed with an error!\n\n";
|
||||||
}
|
}
|
||||||
:local Content [ /file/get ($File . ".txt") content ];
|
:local Content [ /file/get ($File . ".txt") content ];
|
||||||
$SendTelegram2 ({ origin=$0; silent=false; \
|
$SendTelegram2 ({ origin=$0; chatid=$ChatID; silent=false; \
|
||||||
subject=([ $SymbolForNotification "speech-balloon" ] . "Telegram Chat"); \
|
subject=([ $SymbolForNotification "speech-balloon" ] . "Telegram Chat"); \
|
||||||
message=("Command:\n" . $Text . "\n\n" . $State . [ $IfThenElse ([ :len $Content ] > 0) \
|
message=("Command:\n" . $Text . "\n\n" . $State . [ $IfThenElse ([ :len $Content ] > 0) \
|
||||||
("Output:\n" . $Content) "No output available." ]) });
|
("Output:\n" . $Content) "No output available." ]) });
|
||||||
/file/remove "tmpfs/telegram-chat";
|
/file/remove "tmpfs/telegram-chat";
|
||||||
} else={
|
} else={
|
||||||
$SendTelegram2 ({ origin=$0; silent=false; \
|
$SendTelegram2 ({ origin=$0; chatid=$ChatID; silent=false; \
|
||||||
subject=([ $SymbolForNotification "speech-balloon" ] . "Telegram Chat"); \
|
subject=([ $SymbolForNotification "speech-balloon" ] . "Telegram Chat"); \
|
||||||
message=("Command:\n" . $Text . "\n\nThe command failed syntax validation!") });
|
message=("Command:\n" . $Text . "\n\nThe command failed syntax validation!") });
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue