mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-08-03 17:54:41 +02:00
telegram-chat: do not nest conditions
This commit is contained in:
parent
adca33cc5b
commit
555461c612
1 changed files with 4 additions and 3 deletions
|
@ -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" . "'") ] . \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue