diff options
Diffstat (limited to 'sms-forward')
-rw-r--r-- | sms-forward | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/sms-forward b/sms-forward index 8dce464..802da48 100644 --- a/sms-forward +++ b/sms-forward @@ -1,6 +1,7 @@ #!rsc by RouterOS # RouterOS script: sms-forward # Copyright (c) 2013-2023 Christian Hesse <mail@eworm.de> +# Anatoly Bubenkov <bubenkoff@gmail.com> # https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md # # forward SMS to e-mail @@ -11,12 +12,14 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :global Identity; +:global SmsForwardHooks; :global IfThenElse; :global LogPrintExit2; :global ScriptLock; :global SendNotification2; :global SymbolForNotification; +:global ValidateSyntax; :global WaitFullyConnected; $ScriptLock $0; @@ -45,6 +48,25 @@ $WaitFullyConnected; } else={ :set Messages ($Messages . "\n\nOn " . $SmsVal->"timestamp" . \ " type " . $SmsVal->"type" . ":\n" . $SmsVal->"message"); + :foreach Hook in=$SmsForwardHooks do={ + :if ($Phone~($Hook->"allowed-number") && ($SmsVal->"message")~($Hook->"match")) do={ + :if ([ $ValidateSyntax ($Hook->"command") ] = true) do={ + $LogPrintExit2 info $0 ("Running hook '" . $Hook->"match" . "': " . \ + $Hook->"command") false; + :do { + [ :parse ($Hook->"command") ]; + :set Messages ($Messages . "\n\nRan hook '" . $Hook->"match" . "':\n" . \ + $Hook->"command"); + } on-error={ + $LogPrintExit2 warning $0 ("The code for hook '" . $Hook->"match" . \ + "' failed to run!") false; + } + } else={ + $LogPrintExit2 warning $0 ("The code for hook '" . $Hook->"match" . \ + "' failed syntax validation!") false; + } + } + } :set Delete ($Delete, $Sms); } } |