Compare commits

..

3 commits

Author SHA1 Message Date
Christian Hesse
8fc75e00c4 sms-forward: add error handling on message removal 2025-05-07 14:31:37 +02:00
Christian Hesse
2eb3d4d533 sms-forward: delay after removal...
... to give the SIM card some time to succeed. Removing several messages
one after another fails without this.
2025-05-07 11:45:55 +02:00
Christian Hesse
5bacc4052a global-functions: $ScriptInstallUpdate: set config and functions not ready...
... before reload. This should fix some corner cases where scripts ran
with broken configuration or functions.

Also do reload both - configuration and functions - to simplify the
function.
2025-05-07 09:37:09 +02:00

View file

@ -61,7 +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;
:onerror Err {
/tool/sms/inbox/remove $Sms;
:delay 300ms;
} do={
$LogPrint warning $ScriptName ("Failed to remove message: " . $Err);
}
} else={
:set Messages ($Messages . "\n\nOn " . $SmsVal->"timestamp" . \
" type " . $SmsVal->"type" . ":\n" . $SmsVal->"message");
@ -92,7 +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;
:onerror Err {
/tool/sms/inbox/remove $Sms;
:delay 300ms;
} do={
$LogPrint warning $ScriptName ("Failed to remove message: " . $Err);
}
}
}
}