mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2025-12-28 04:39:31 +00:00
sms-forward: support hooks
This commit is contained in:
parent
88b34cfb39
commit
ea09a18d3f
5 changed files with 60 additions and 1 deletions
22
sms-forward
22
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue