sms-forward: get values into arrays

This commit is contained in:
Christian Hesse 2019-07-25 13:17:51 +02:00
parent cc9b2620e7
commit 1c4dfeaa4a

View file

@ -14,8 +14,7 @@
:error "Warning: See log for details."; :error "Warning: See log for details.";
} }
:local Allowed [ / tool sms get allowed-number ]; :local Settings [ / tool sms get ];
:local Secret [ / tool sms get secret ];
# forward SMS in a loop # forward SMS in a loop
:while ([ / tool sms inbox print count-only ] > 0) do={ :while ([ / tool sms inbox print count-only ] > 0) do={
@ -24,16 +23,14 @@
: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 Message [ / tool sms inbox get $Sms message ]; :local SmsVal [ / tool sms inbox get $Sms ];
:local TimeStamp [ / tool sms inbox get $Sms timestamp ];
:local Type [ / tool sms inbox get $Sms type ];
:if ($Phone = $Allowed && $Message~("^:cmd " . $Secret . " script ")) do={ :if ($Phone = $Settings->"allowed" && ($SmsVal->"message")~("^:cmd " . $Settings->"secret" . " script ")) do={
:log debug "Removing SMS, which started a script."; :log debug "Removing SMS, which started a script.";
/ tool sms inbox remove $Sms; / tool sms inbox remove $Sms;
} else={ } else={
:set Messages ($Messages . "\n\nOn " . $TimeStamp . \ :set Messages ($Messages . "\n\nOn " . $SmsVal->"timestamp" . \
" type " . $Type . ":\n" . $Message); " type " . $SmsVal->"type" . ":\n" . $SmsVal->"message");
:set Delete ($Delete, $Sms); :set Delete ($Delete, $Sms);
} }
} }