aboutsummaryrefslogtreecommitdiffstats
path: root/telegram-chat.rsc
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2023-10-16 12:50:50 +0200
committerGravatar Christian Hesse <mail@eworm.de>2023-10-16 15:27:14 +0200
commit555461c6121465aab748429d6a3226b1a6ca42b4 (patch)
tree5cba60f125349156f089840641b5a51d3320d662 /telegram-chat.rsc
parentadca33cc5bcc68911bc811d4b40f387e6b1afd97 (diff)
telegram-chat: do not nest conditions
Diffstat (limited to 'telegram-chat.rsc')
-rw-r--r--telegram-chat.rsc7
1 files changed, 4 insertions, 3 deletions
diff --git a/telegram-chat.rsc b/telegram-chat.rsc
index f71cbde..9afac69 100644
--- a/telegram-chat.rsc
+++ b/telegram-chat.rsc
@@ -76,6 +76,7 @@ $WaitFullyConnected;
}
:if ($Trusted = true) do={
+ :local Done false;
:if ([ :pick ($Message->"text") 0 1 ] = "!") do={
:if ($Message->"text" ~ ("^! *(" . [ $EscapeForRegEx $Identity ] . "|@" . $TelegramChatGroups . ")\$")) do={
:set TelegramChatActive true;
@@ -84,8 +85,9 @@ $WaitFullyConnected;
}
$LogPrintExit2 info $0 ("Now " . [ $IfThenElse $TelegramChatActive "active" "passive" ] . \
" from update " . $UpdateID . "!") false;
- } else={
- :if (($IsReply = 1 || $TelegramChatActive = true) && [ :len ($Message->"text") ] > 0) do={
+ :set Done true;
+ }
+ :if ($Done = false && ($IsReply = 1 || $TelegramChatActive = true) && [ :len ($Message->"text") ] > 0) do={
:if ([ $ValidateSyntax ($Message->"text") ] = true) do={
:local State "";
:local File ("tmpfs/telegram-chat/" . [ $GetRandom20CharAlNum 6 ]);
@@ -113,7 +115,6 @@ $WaitFullyConnected;
message=("Command:\n" . $Message->"text" . "\n\nThe command failed syntax validation!") });
}
}
- }
} else={
:local MessageText ("Received a message from untrusted contact " . \
[ $IfThenElse ([ :len ($From->"username") ] = 0) "without username" ("'" . $From->"username" . "'") ] . \