aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2023-02-02 09:48:43 +0100
committerGravatar Christian Hesse <mail@eworm.de>2023-02-02 10:06:42 +0100
commitb794d98cbb513f7ef49ffd4e19101e4580e96949 (patch)
tree73ffca5f202b596c090dd7a427dbccb4f1168f2d
parent08383daa5c03f0621a59010bf86b5cea1b032471 (diff)
telegram-chat: reply with a hint when untrusted...
... but only when activating via identity.
-rw-r--r--telegram-chat7
1 files changed, 6 insertions, 1 deletions
diff --git a/telegram-chat b/telegram-chat
index f5b0f63..93d4294 100644
--- a/telegram-chat
+++ b/telegram-chat
@@ -79,6 +79,7 @@ $WaitFullyConnected;
:local FromID [ $JsonGetKey $From "id" ];
:local FromUserName [ $JsonGetKey $From "username" ];
:local ChatID [ $JsonGetKey [ $JsonGetKey $Message "chat" ] "id" ];
+ :local Text [ $JsonGetKey $Message "text" ];
:foreach IdsTrusted in=($TelegramChatId, $TelegramChatIdsTrusted) do={
:if ($FromID = $IdsTrusted || $FromUserName = $IdsTrusted) do={
:set Trusted true;
@@ -86,7 +87,6 @@ $WaitFullyConnected;
}
:if ($Trusted = true) do={
- :local Text [ $JsonGetKey $Message "text" ];
:if ([ :pick $Text 0 1 ] = "!") do={
:if ($Text ~ ("^! *(" . [ $EscapeForRegEx $Identity ] . "|@" . $TelegramChatGroups . ")\$")) do={
:set TelegramChatActive true;
@@ -124,6 +124,11 @@ $WaitFullyConnected;
}
} else={
$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.") });
+ }
}
}
}