aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2018-09-23 22:27:01 +0200
committerGravatar Christian Hesse <mail@eworm.de>2018-09-23 22:27:01 +0200
commit4273459f11b00fe59485e6e4ef09be50725efc9a (patch)
tree77c1e56cd48ea25cf37fe86b6089891656a63f9a
parent2b09b1974ad52f85a823b645344c82925b6bfa24 (diff)
sms-forward: make handling of SMS with action more robust
-rw-r--r--sms-forward26
1 files changed, 17 insertions, 9 deletions
diff --git a/sms-forward b/sms-forward
index df0a070..febe3eb 100644
--- a/sms-forward
+++ b/sms-forward
@@ -13,18 +13,26 @@
:error "Mail server is not up.";
}
+:local allowed [ / tool sms get allowed-number ];
+:local secret [ / tool sms get secret ];
+
# 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 phone [ / tool sms inbox get $sms phone ];
:local timestamp [ / tool sms inbox get $sms timestamp ];
:local type [ / tool sms inbox get $sms type ];
- / tool e-mail send to=$"email-general-to" cc=$"email-general-cc" \
- subject=("[" . $identity . "] SMS Forwarding") \
- body=("A message was received by " . $identity . ":\n\n" . \
- "Phone: " . $phone . "\n" . \
- "Timestamp: " . $timestamp . "\n" . \
- "Type: " . $type . "\n\n" . \
- "Message:\n" . $message);
- / tool sms inbox remove $sms;
+
+ :if ($phone = $allowed && message~("^:cmd " . $secret . " script ")) do={
+ :log debug "Ignoring SMS, which starts a script.";
+ } else={
+ / tool e-mail send to=$"email-general-to" cc=$"email-general-cc" \
+ subject=("[" . $identity . "] SMS Forwarding") \
+ body=("A message was received by " . $identity . ":\n\n" . \
+ "Phone: " . $phone . "\n" . \
+ "Timestamp: " . $timestamp . "\n" . \
+ "Type: " . $type . "\n\n" . \
+ "Message:\n" . $message);
+ / tool sms inbox remove $sms;
+ }
}