telegram-chat: use $ExitError to indicate unintentional error

This commit is contained in:
Christian Hesse 2024-12-06 10:31:52 +01:00
parent a78fe98fd0
commit adbefca0e4

View file

@ -11,6 +11,7 @@
:global GlobalFunctionsReady; :global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:local ExitOK false;
:do { :do {
:local ScriptName [ :jobname ]; :local ScriptName [ :jobname ];
@ -43,6 +44,7 @@
:global WaitFullyConnected; :global WaitFullyConnected;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true;
:error false; :error false;
} }
@ -57,6 +59,7 @@
:if ([ $CertificateAvailable "Go Daddy Root Certificate Authority - G2" ] = false) do={ :if ([ $CertificateAvailable "Go Daddy Root Certificate Authority - G2" ] = false) do={
$LogPrint warning $ScriptName ("Downloading required certificate failed."); $LogPrint warning $ScriptName ("Downloading required certificate failed.");
:set ExitOK true;
:error false; :error false;
} }
@ -82,6 +85,7 @@
:if ($Data = false) do={ :if ($Data = false) do={
$LogPrint warning $ScriptName ("Failed getting updates."); $LogPrint warning $ScriptName ("Failed getting updates.");
:set ExitOK true;
:error false; :error false;
} }
@ -130,6 +134,7 @@
:local File ("tmpfs/telegram-chat/" . [ $GetRandom20CharAlNum 6 ]); :local File ("tmpfs/telegram-chat/" . [ $GetRandom20CharAlNum 6 ]);
:if ([ $MkDir "tmpfs/telegram-chat" ] = false) do={ :if ([ $MkDir "tmpfs/telegram-chat" ] = false) do={
$LogPrint error $ScriptName ("Failed creating directory!"); $LogPrint error $ScriptName ("Failed creating directory!");
:set ExitOK true;
:error false; :error false;
} }
$LogPrint info $ScriptName ("Running command from update " . $UpdateID . ": " . $Command); $LogPrint info $ScriptName ("Running command from update " . $UpdateID . ": " . $Command);
@ -176,4 +181,6 @@
} }
:set TelegramChatOffset ([ :pick $TelegramChatOffset 1 3 ], \ :set TelegramChatOffset ([ :pick $TelegramChatOffset 1 3 ], \
[ $IfThenElse ($UpdateID >= $TelegramChatOffset->2) ($UpdateID + 1) ($TelegramChatOffset->2) ]); [ $IfThenElse ($UpdateID >= $TelegramChatOffset->2) ($UpdateID + 1) ($TelegramChatOffset->2) ]);
} on-error={ } } on-error={
:global ExitError; $ExitError $ExitOK [ :jobname ];
}