1
0
mirror of https://github.com/eworm-de/routeros-scripts.git synced 2024-05-11 05:55:19 +00:00

sms-forward: group messages for same sender

This commit is contained in:
Christian Hesse
2019-04-04 14:06:44 +02:00
parent 15d3e9ea7b
commit 2e10a80f95

View File

@ -18,21 +18,32 @@
:local Secret [ / tool sms get secret ]; :local Secret [ / tool sms get secret ];
# forward SMS in a loop # forward SMS in a loop
:foreach Sms in=[ / tool sms inbox find ] do={ :while ([ / tool sms inbox print count-only ] > 0) do={
:local Phone [ / tool sms inbox get ([ find ]->0) phone ];
:local Messages "";
:local Delete [ :toarray "" ];
:foreach Sms in=[ / tool sms inbox find where phone=$Phone ] 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 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 ];
:if ($Phone = $Allowed && $Message~("^:cmd " . $Secret . " script ")) do={ :if ($Phone = $Allowed && $Message~("^:cmd " . $Secret . " script ")) do={
:log debug "Ignoring SMS, which starts a script."; :log debug "Removing SMS, which started a script.";
/ tool sms inbox remove $Sms;
} else={ } else={
:set Messages ($Messages . "\n\nOn " . $TimeStamp . \
" type " . $Type . ":\n" . $Message);
:set Delete ($Delete, $Sms);
}
}
:if ([ :len $Messages ] > 0) do={
$SendNotification ("SMS Forwarding") \ $SendNotification ("SMS Forwarding") \
("A message was received by " . $Identity . ":\n\n" . \ ("These message(s) were received by " . $Identity . \
"Phone: " . $Phone . "\n" . \ " from " . $Phone . ":" . $Messages);
"Timestamp: " . $TimeStamp . "\n" . \ :foreach Sms in=$Delete do={
"Type: " . $Type . "\n\n" . \
"Message:\n" . $Message);
/ tool sms inbox remove $Sms; / tool sms inbox remove $Sms;
} }
} }
}