aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2023-02-01 11:01:59 +0100
committerGravatar Christian Hesse <mail@eworm.de>2023-02-01 11:29:56 +0100
commit44c30efbcd77f85a92595d06e4531fca1461f101 (patch)
tree5df8d5af23cd7db6905d217d44cda12fbe43d99c
parent7e7987afec9e8bbbaecb9c84d267097568d7edc7 (diff)
telegram-chat: give a hint if command is still running
-rw-r--r--telegram-chat5
1 files changed, 3 insertions, 2 deletions
diff --git a/telegram-chat b/telegram-chat
index 9c8261e..aeb4e6d 100644
--- a/telegram-chat
+++ b/telegram-chat
@@ -96,17 +96,18 @@ $WaitFullyConnected;
} else={
:if ($TelegramChatActive = true && [ :len $Text ] > 0) do={
:if ([ $ValidateSyntax $Text ] = true) do={
+ :local State "";
:local File ("tmpfs/telegram-chat/" . [ $GetRandom20CharAlNum 6 ]);
$MkDir "tmpfs/telegram-chat";
$LogPrintExit2 info $0 ("Running command: " . $Text) false;
:exec script=($Text . "; :execute script=\":put\" file=" . $File . ".done") file=$File;
:if ([ $WaitForFile ($File . ".done.txt") 200 ] = false) do={
- $LogPrintExit2 warning $0 ("Command did not finish, possibly still running.") false;
+ :set State "The command did not finish, still running in background.\n\n";
}
:local Content [ /file/get ($File . ".txt") content ];
$SendTelegram2 ({ origin=$0; silent=false; \
subject=([ $SymbolForNotification "speech-balloon" ] . "Telegram Chat"); \
- message=("Command:\n" . $Text . "\n\nOutput:\n" . $Content) });
+ message=("Command:\n" . $Text . "\n\n" . $State . "Output:\n" . $Content) });
/file/remove "tmpfs/telegram-chat";
} else={
$LogPrintExit2 warning $0 ("The command failed syntax validation: " . $Text) false;