aboutsummaryrefslogtreecommitdiffstats
path: root/sms-forward
diff options
context:
space:
mode:
authorGravatar Anatoly Bubenkov <bubenkoff@gmail.com>2022-11-03 23:43:08 +0100
committerGravatar Christian Hesse <mail@eworm.de>2023-01-10 08:58:33 +0100
commitea09a18d3f05b20ff7f1ec25aea74f32d68ca5e0 (patch)
treed873298ae7c1557552d6db38e75cbaf11764e4fb /sms-forward
parent88b34cfb39775560654d60d91da33681b9899251 (diff)
sms-forward: support hookschange-86
Diffstat (limited to 'sms-forward')
-rw-r--r--sms-forward22
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);
}
}