mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
telegram-chat: send messages in reply
This commit is contained in:
parent
b963761874
commit
5ea892662f
1 changed files with 4 additions and 3 deletions
|
@ -77,6 +77,7 @@ $WaitFullyConnected;
|
||||||
:if ($UpdateID >= $TelegramChatOffset->2) do={
|
:if ($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 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" ];
|
||||||
|
@ -113,7 +114,7 @@ $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") contents ];
|
:local Content [ /file/get ($File . ".txt") contents ];
|
||||||
$SendTelegram2 ({ origin=$0; chatid=$ChatID; silent=false; \
|
$SendTelegram2 ({ origin=$0; chatid=$ChatID; silent=false; replyto=$MessageId; \
|
||||||
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) [ $IfThenElse ([ /file/get ($File . ".txt") size ] > 0) \
|
("Output:\n" . $Content) [ $IfThenElse ([ /file/get ($File . ".txt") size ] > 0) \
|
||||||
|
@ -121,7 +122,7 @@ $WaitFullyConnected;
|
||||||
/file/remove "tmpfs/telegram-chat";
|
/file/remove "tmpfs/telegram-chat";
|
||||||
} else={
|
} else={
|
||||||
$LogPrintExit2 info $0 ("The command from update " . $UpdateID . " failed syntax validation!") false;
|
$LogPrintExit2 info $0 ("The command from update " . $UpdateID . " failed syntax validation!") false;
|
||||||
$SendTelegram2 ({ origin=$0; chatid=$ChatID; silent=false; \
|
$SendTelegram2 ({ origin=$0; chatid=$ChatID; silent=false; replyto=$MessageId; \
|
||||||
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!") });
|
||||||
}
|
}
|
||||||
|
@ -133,7 +134,7 @@ $WaitFullyConnected;
|
||||||
" (ID " . $FromID . ") in update " . $UpdateID . "!");
|
" (ID " . $FromID . ") in update " . $UpdateID . "!");
|
||||||
:if ($Text ~ ("^! *" . [ $EscapeForRegEx $Identity ] . "\$")) do={
|
:if ($Text ~ ("^! *" . [ $EscapeForRegEx $Identity ] . "\$")) do={
|
||||||
$LogPrintExit2 warning $0 $Message false;
|
$LogPrintExit2 warning $0 $Message false;
|
||||||
$SendTelegram2 ({ origin=$0; chatid=$ChatID; silent=false; \
|
$SendTelegram2 ({ origin=$0; chatid=$ChatID; silent=false; replyto=$MessageId; \
|
||||||
subject=([ $SymbolForNotification "speech-balloon" ] . "Telegram Chat"); \
|
subject=([ $SymbolForNotification "speech-balloon" ] . "Telegram Chat"); \
|
||||||
message=("You are not trusted.") });
|
message=("You are not trusted.") });
|
||||||
} else={
|
} else={
|
||||||
|
|
Loading…
Reference in a new issue