mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2025-08-19 09:08:56 +02:00
telegram-chat: reply with a hint when untrusted...
... but only when activating via identity.
This commit is contained in:
parent
08383daa5c
commit
b794d98cbb
1 changed files with 6 additions and 1 deletions
|
@ -79,6 +79,7 @@ $WaitFullyConnected;
|
||||||
: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" ];
|
:local ChatID [ $JsonGetKey [ $JsonGetKey $Message "chat" ] "id" ];
|
||||||
|
:local Text [ $JsonGetKey $Message "text" ];
|
||||||
: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;
|
||||||
|
@ -86,7 +87,6 @@ $WaitFullyConnected;
|
||||||
}
|
}
|
||||||
|
|
||||||
:if ($Trusted = true) do={
|
:if ($Trusted = true) do={
|
||||||
:local Text [ $JsonGetKey $Message "text" ];
|
|
||||||
:if ([ :pick $Text 0 1 ] = "!") do={
|
:if ([ :pick $Text 0 1 ] = "!") do={
|
||||||
:if ($Text ~ ("^! *(" . [ $EscapeForRegEx $Identity ] . "|@" . $TelegramChatGroups . ")\$")) do={
|
:if ($Text ~ ("^! *(" . [ $EscapeForRegEx $Identity ] . "|@" . $TelegramChatGroups . ")\$")) do={
|
||||||
:set TelegramChatActive true;
|
:set TelegramChatActive true;
|
||||||
|
@ -124,6 +124,11 @@ $WaitFullyConnected;
|
||||||
}
|
}
|
||||||
} else={
|
} else={
|
||||||
$LogPrintExit2 warning $0 ("Received a message from untrusted contact '" . $FromUserName . "' (ID " . $FromID . ")!") false;
|
$LogPrintExit2 warning $0 ("Received a message from untrusted contact '" . $FromUserName . "' (ID " . $FromID . ")!") false;
|
||||||
|
:if ($Text ~ ("^! *" . [ $EscapeForRegEx $Identity ] . "\$")) do={
|
||||||
|
$SendTelegram2 ({ origin=$0; chatid=$ChatID; silent=false; \
|
||||||
|
subject=([ $SymbolForNotification "speech-balloon" ] . "Telegram Chat"); \
|
||||||
|
message=("You are not trusted.") });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue