mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-06-21 01:15:42 +02:00
sms-forward: add error handling on message removal
This commit is contained in:
parent
9085780562
commit
01f3cb91e7
1 changed files with 12 additions and 4 deletions
|
@ -61,8 +61,12 @@
|
|||
:if ($Phone = $Settings->"allowed-number" && \
|
||||
($SmsVal->"message")~("^:cmd " . $Settings->"secret" . " script ")) do={
|
||||
$LogPrint debug $ScriptName ("Removing SMS, which started a script.");
|
||||
/tool/sms/inbox/remove $Sms;
|
||||
:delay 50ms;
|
||||
:onerror Err {
|
||||
/tool/sms/inbox/remove $Sms;
|
||||
:delay 50ms;
|
||||
} do={
|
||||
$LogPrint warning $ScriptName ("Failed to remove message: " . $Err);
|
||||
}
|
||||
} else={
|
||||
:set Messages ($Messages . "\n\nOn " . $SmsVal->"timestamp" . \
|
||||
" type " . $SmsVal->"type" . ":\n" . $SmsVal->"message");
|
||||
|
@ -93,8 +97,12 @@
|
|||
message=("Received " . [ $IfThenElse ($Count = 1) "this message" ("these " . $Count . " messages") ] . \
|
||||
" by " . $Identity . " from " . $Phone . ":" . $Messages) });
|
||||
:foreach Sms in=$Delete do={
|
||||
/tool/sms/inbox/remove $Sms;
|
||||
:delay 50ms;
|
||||
:onerror Err {
|
||||
/tool/sms/inbox/remove $Sms;
|
||||
:delay 50ms;
|
||||
} do={
|
||||
$LogPrint warning $ScriptName ("Failed to remove message: " . $Err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue