mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-07-15 04:24:29 +02:00
sms-forward: make handling of SMS with action more robust
This commit is contained in:
parent
2b09b1974a
commit
4273459f11
1 changed files with 17 additions and 9 deletions
26
sms-forward
26
sms-forward
|
@ -13,18 +13,26 @@
|
||||||
:error "Mail server is not up.";
|
:error "Mail server is not up.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:local allowed [ / tool sms get allowed-number ];
|
||||||
|
:local secret [ / tool sms get secret ];
|
||||||
|
|
||||||
# forward SMS in a loop
|
# forward SMS in a loop
|
||||||
:foreach sms in=[ / tool sms inbox find where message~"^([^:][^c][^m][^d][^ ])" ] do={
|
:foreach sms in=[ / tool sms inbox find ] do={
|
||||||
:local message [ / tool sms inbox get $sms message ];
|
:local message [ / tool sms inbox get $sms message ];
|
||||||
:local phone [ / tool sms inbox get $sms phone ];
|
:local phone [ / tool sms inbox get $sms phone ];
|
||||||
:local timestamp [ / tool sms inbox get $sms timestamp ];
|
:local timestamp [ / tool sms inbox get $sms timestamp ];
|
||||||
:local type [ / tool sms inbox get $sms type ];
|
:local type [ / tool sms inbox get $sms type ];
|
||||||
/ tool e-mail send to=$"email-general-to" cc=$"email-general-cc" \
|
|
||||||
subject=("[" . $identity . "] SMS Forwarding") \
|
:if ($phone = $allowed && message~("^:cmd " . $secret . " script ")) do={
|
||||||
body=("A message was received by " . $identity . ":\n\n" . \
|
:log debug "Ignoring SMS, which starts a script.";
|
||||||
"Phone: " . $phone . "\n" . \
|
} else={
|
||||||
"Timestamp: " . $timestamp . "\n" . \
|
/ tool e-mail send to=$"email-general-to" cc=$"email-general-cc" \
|
||||||
"Type: " . $type . "\n\n" . \
|
subject=("[" . $identity . "] SMS Forwarding") \
|
||||||
"Message:\n" . $message);
|
body=("A message was received by " . $identity . ":\n\n" . \
|
||||||
/ tool sms inbox remove $sms;
|
"Phone: " . $phone . "\n" . \
|
||||||
|
"Timestamp: " . $timestamp . "\n" . \
|
||||||
|
"Type: " . $type . "\n\n" . \
|
||||||
|
"Message:\n" . $message);
|
||||||
|
/ tool sms inbox remove $sms;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue