From 555461c6121465aab748429d6a3226b1a6ca42b4 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 16 Oct 2023 12:50:50 +0200 Subject: telegram-chat: do not nest conditions --- telegram-chat.rsc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'telegram-chat.rsc') 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" . "'") ] . \ -- cgit v1.2.3-54-g00ecf