telegram-chat: add updateid in log messages

This commit is contained in:
Christian Hesse 2023-02-14 21:28:15 +01:00
parent c48509683c
commit 2a7576f4e4

View file

@ -95,14 +95,15 @@ $WaitFullyConnected;
} else={ } else={
:set TelegramChatActive false; :set TelegramChatActive false;
} }
$LogPrintExit2 info $0 ("Now " . [ $IfThenElse $TelegramChatActive "active" "passive" ] . "!") false; $LogPrintExit2 info $0 ("Now " . [ $IfThenElse $TelegramChatActive "active" "passive" ] . \
" from update " . $UpdateID . "!") false;
} else={ } else={
:if ($TelegramChatActive = true && $Text != false && [ :len $Text ] > 0) do={ :if ($TelegramChatActive = true && $Text != false && [ :len $Text ] > 0) do={
:if ([ $ValidateSyntax $Text ] = true) do={ :if ([ $ValidateSyntax $Text ] = true) do={
:local State ""; :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 from update " . $UpdateID . ": " . $Text) false;
:exec script=(":do {\n" . $Text . "\n} on-error={ :execute script=\"/\" file=" . $File . ".failed };" . \ :exec script=(":do {\n" . $Text . "\n} on-error={ :execute script=\"/\" file=" . $File . ".failed };" . \
":execute script=\"/\" file=" . $File . ".done") file=$File; ":execute script=\"/\" file=" . $File . ".done") file=$File;
:if ([ $WaitForFile ($File . ".done.txt") [ $EitherOr $TelegramChatRunTime 20s ] ] = false) do={ :if ([ $WaitForFile ($File . ".done.txt") [ $EitherOr $TelegramChatRunTime 20s ] ] = false) do={
@ -128,7 +129,7 @@ $WaitFullyConnected;
} else={ } else={
:local Message ("Received a message from untrusted contact " . \ :local Message ("Received a message from untrusted contact " . \
[ $IfThenElse ($FromUserName = false) "without username" ("'" . $FromUserName . "'") ] . \ [ $IfThenElse ($FromUserName = false) "without username" ("'" . $FromUserName . "'") ] . \
" (ID " . $FromID . ")!"); " (ID " . $FromID . ") in update " . $UpdateID . "!");
:if ($Text ~ ("^! *" . [ $EscapeForRegEx $Identity ] . "\$")) do={ :if ($Text ~ ("^! *" . [ $EscapeForRegEx $Identity ] . "\$")) do={
$LogPrintExit2 warning $0 $Message false; $LogPrintExit2 warning $0 $Message false;
$SendTelegram2 ({ origin=$0; chatid=$ChatID; silent=false; \ $SendTelegram2 ({ origin=$0; chatid=$ChatID; silent=false; \