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:
27
sms-forward
27
sms-forward
@ -18,21 +18,32 @@
|
||||
:local Secret [ / tool sms get secret ];
|
||||
|
||||
# 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 Phone [ / tool sms inbox get $Sms phone ];
|
||||
:local TimeStamp [ / tool sms inbox get $Sms timestamp ];
|
||||
:local Type [ / tool sms inbox get $Sms type ];
|
||||
|
||||
: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={
|
||||
:set Messages ($Messages . "\n\nOn " . $TimeStamp . \
|
||||
" type " . $Type . ":\n" . $Message);
|
||||
:set Delete ($Delete, $Sms);
|
||||
}
|
||||
}
|
||||
|
||||
:if ([ :len $Messages ] > 0) do={
|
||||
$SendNotification ("SMS Forwarding") \
|
||||
("A message was received by " . $Identity . ":\n\n" . \
|
||||
"Phone: " . $Phone . "\n" . \
|
||||
"Timestamp: " . $TimeStamp . "\n" . \
|
||||
"Type: " . $Type . "\n\n" . \
|
||||
"Message:\n" . $Message);
|
||||
("These message(s) were received by " . $Identity . \
|
||||
" from " . $Phone . ":" . $Messages);
|
||||
:foreach Sms in=$Delete do={
|
||||
/ tool sms inbox remove $Sms;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user