mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
sms-forward: RouterOS v7 path syntax
This commit is contained in:
parent
735df85b45
commit
fbc6852687
1 changed files with 8 additions and 8 deletions
16
sms-forward
16
sms-forward
|
@ -21,27 +21,27 @@
|
||||||
|
|
||||||
$ScriptLock $0;
|
$ScriptLock $0;
|
||||||
|
|
||||||
:if ([ / tool sms get receive-enabled ] = false) do={
|
:if ([ /tool/sms/get receive-enabled ] = false) do={
|
||||||
$LogPrintExit2 warning $0 ("Receiving of SMS is not enabled.") true;
|
$LogPrintExit2 warning $0 ("Receiving of SMS is not enabled.") true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$WaitFullyConnected;
|
$WaitFullyConnected;
|
||||||
|
|
||||||
:local Settings [ / tool sms get ];
|
:local Settings [ /tool/sms/get ];
|
||||||
|
|
||||||
# forward SMS in a loop
|
# forward SMS in a loop
|
||||||
:while ([ :len [ / tool sms inbox find ] ] > 0) do={
|
:while ([ :len [ /tool/sms/inbox/find ] ] > 0) do={
|
||||||
:local Phone [ / tool sms inbox get ([ find ]->0) phone ];
|
:local Phone [ /tool/sms/inbox/get ([ find ]->0) phone ];
|
||||||
:local Messages "";
|
:local Messages "";
|
||||||
:local Delete [ :toarray "" ];
|
:local Delete [ :toarray "" ];
|
||||||
|
|
||||||
:foreach Sms in=[ / tool sms inbox find where phone=$Phone ] do={
|
:foreach Sms in=[ /tool/sms/inbox/find where phone=$Phone ] do={
|
||||||
:local SmsVal [ / tool sms inbox get $Sms ];
|
:local SmsVal [ /tool/sms/inbox/get $Sms ];
|
||||||
|
|
||||||
:if ($Phone = $Settings->"allowed-number" && \
|
:if ($Phone = $Settings->"allowed-number" && \
|
||||||
($SmsVal->"message")~("^:cmd " . $Settings->"secret" . " script ")) do={
|
($SmsVal->"message")~("^:cmd " . $Settings->"secret" . " script ")) do={
|
||||||
$LogPrintExit2 debug $0 ("Removing SMS, which started a script.") false;
|
$LogPrintExit2 debug $0 ("Removing SMS, which started a script.") false;
|
||||||
/ tool sms inbox remove $Sms;
|
/tool/sms/inbox/remove $Sms;
|
||||||
} else={
|
} else={
|
||||||
:set Messages ($Messages . "\n\nOn " . $SmsVal->"timestamp" . \
|
:set Messages ($Messages . "\n\nOn " . $SmsVal->"timestamp" . \
|
||||||
" type " . $SmsVal->"type" . ":\n" . $SmsVal->"message");
|
" type " . $SmsVal->"type" . ":\n" . $SmsVal->"message");
|
||||||
|
@ -56,7 +56,7 @@ $WaitFullyConnected;
|
||||||
message=("Received " . [ $IfThenElse ($Count = 1) "this message" ("these " . $Count . " messages") ] . \
|
message=("Received " . [ $IfThenElse ($Count = 1) "this message" ("these " . $Count . " messages") ] . \
|
||||||
" by " . $Identity . " from " . $Phone . ":" . $Messages) });
|
" by " . $Identity . " from " . $Phone . ":" . $Messages) });
|
||||||
:foreach Sms in=$Delete do={
|
:foreach Sms in=$Delete do={
|
||||||
/ tool sms inbox remove $Sms;
|
/tool/sms/inbox/remove $Sms;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue