From 5ea892662f94d817ff325abe21620665efde24fa Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 23 Feb 2023 22:07:37 +0100 Subject: telegram-chat: send messages in reply --- telegram-chat | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/telegram-chat b/telegram-chat index 882ce55..8b7fa5f 100644 --- a/telegram-chat +++ b/telegram-chat @@ -77,6 +77,7 @@ $WaitFullyConnected; :if ($UpdateID >= $TelegramChatOffset->2) do={ :local Trusted false; :local Message [ $JsonGetKey $Update "message" ]; + :local MessageId [ $JsonGetKey $Message "message_id" ]; :local From [ $JsonGetKey $Message "from" ]; :local FromID [ $JsonGetKey $From "id" ]; :local FromUserName [ $JsonGetKey $From "username" ]; @@ -113,7 +114,7 @@ $WaitFullyConnected; :set State "The command failed with an error!\n\n"; } :local Content [ /file/get ($File . ".txt") contents ]; - $SendTelegram2 ({ origin=$0; chatid=$ChatID; silent=false; \ + $SendTelegram2 ({ origin=$0; chatid=$ChatID; silent=false; replyto=$MessageId; \ subject=([ $SymbolForNotification "speech-balloon" ] . "Telegram Chat"); \ message=("Command:\n" . $Text . "\n\n" . $State . [ $IfThenElse ([ :len $Content ] > 0) \ ("Output:\n" . $Content) [ $IfThenElse ([ /file/get ($File . ".txt") size ] > 0) \ @@ -121,7 +122,7 @@ $WaitFullyConnected; /file/remove "tmpfs/telegram-chat"; } else={ $LogPrintExit2 info $0 ("The command from update " . $UpdateID . " failed syntax validation!") false; - $SendTelegram2 ({ origin=$0; chatid=$ChatID; silent=false; \ + $SendTelegram2 ({ origin=$0; chatid=$ChatID; silent=false; replyto=$MessageId; \ subject=([ $SymbolForNotification "speech-balloon" ] . "Telegram Chat"); \ message=("Command:\n" . $Text . "\n\nThe command failed syntax validation!") }); } @@ -133,7 +134,7 @@ $WaitFullyConnected; " (ID " . $FromID . ") in update " . $UpdateID . "!"); :if ($Text ~ ("^! *" . [ $EscapeForRegEx $Identity ] . "\$")) do={ $LogPrintExit2 warning $0 $Message false; - $SendTelegram2 ({ origin=$0; chatid=$ChatID; silent=false; \ + $SendTelegram2 ({ origin=$0; chatid=$ChatID; silent=false; replyto=$MessageId; \ subject=([ $SymbolForNotification "speech-balloon" ] . "Telegram Chat"); \ message=("You are not trusted.") }); } else={ -- cgit v1.2.3-54-g00ecf