mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
telegram-chat: give a hint if command is still running
This commit is contained in:
parent
7e7987afec
commit
44c30efbcd
1 changed files with 3 additions and 2 deletions
|
@ -96,17 +96,18 @@ $WaitFullyConnected;
|
||||||
} else={
|
} else={
|
||||||
:if ($TelegramChatActive = true && [ :len $Text ] > 0) do={
|
:if ($TelegramChatActive = true && [ :len $Text ] > 0) do={
|
||||||
:if ([ $ValidateSyntax $Text ] = true) do={
|
:if ([ $ValidateSyntax $Text ] = true) do={
|
||||||
|
:local State "";
|
||||||
:local File ("tmpfs/telegram-chat/" . [ $GetRandom20CharAlNum 6 ]);
|
:local File ("tmpfs/telegram-chat/" . [ $GetRandom20CharAlNum 6 ]);
|
||||||
$MkDir "tmpfs/telegram-chat";
|
$MkDir "tmpfs/telegram-chat";
|
||||||
$LogPrintExit2 info $0 ("Running command: " . $Text) false;
|
$LogPrintExit2 info $0 ("Running command: " . $Text) false;
|
||||||
:exec script=($Text . "; :execute script=\":put\" file=" . $File . ".done") file=$File;
|
:exec script=($Text . "; :execute script=\":put\" file=" . $File . ".done") file=$File;
|
||||||
:if ([ $WaitForFile ($File . ".done.txt") 200 ] = false) do={
|
: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 ];
|
:local Content [ /file/get ($File . ".txt") content ];
|
||||||
$SendTelegram2 ({ origin=$0; silent=false; \
|
$SendTelegram2 ({ origin=$0; silent=false; \
|
||||||
subject=([ $SymbolForNotification "speech-balloon" ] . "Telegram Chat"); \
|
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";
|
/file/remove "tmpfs/telegram-chat";
|
||||||
} else={
|
} else={
|
||||||
$LogPrintExit2 warning $0 ("The command failed syntax validation: " . $Text) false;
|
$LogPrintExit2 warning $0 ("The command failed syntax validation: " . $Text) false;
|
||||||
|
|
Loading…
Reference in a new issue