From 08383daa5c03f0621a59010bf86b5cea1b032471 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 2 Feb 2023 09:24:19 +0100 Subject: telegram-chat: always reply to origin chat --- doc/telegram-chat.md | 2 +- telegram-chat | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/telegram-chat.md b/doc/telegram-chat.md index fe0d2d6..c3ef7fc 100644 --- a/doc/telegram-chat.md +++ b/doc/telegram-chat.md @@ -105,7 +105,7 @@ it to receive messages you have to make it an admin of that group! It is fine to deny all permissions, though. Also adding an admin to a group can cause the group id to change, so check -that if things break suddenly. +that if notifications break suddenly. See also -------- diff --git a/telegram-chat b/telegram-chat index 317f030..f5b0f63 100644 --- a/telegram-chat +++ b/telegram-chat @@ -78,6 +78,7 @@ $WaitFullyConnected; :local From [ $JsonGetKey $Message "from" ]; :local FromID [ $JsonGetKey $From "id" ]; :local FromUserName [ $JsonGetKey $From "username" ]; + :local ChatID [ $JsonGetKey [ $JsonGetKey $Message "chat" ] "id" ]; :foreach IdsTrusted in=($TelegramChatId, $TelegramChatIdsTrusted) do={ :if ($FromID = $IdsTrusted || $FromUserName = $IdsTrusted) do={ :set Trusted true; @@ -109,13 +110,13 @@ $WaitFullyConnected; :set State "The command failed with an error!\n\n"; } :local Content [ /file/get ($File . ".txt") content ]; - $SendTelegram2 ({ origin=$0; silent=false; \ + $SendTelegram2 ({ origin=$0; chatid=$ChatID; silent=false; \ subject=([ $SymbolForNotification "speech-balloon" ] . "Telegram Chat"); \ message=("Command:\n" . $Text . "\n\n" . $State . [ $IfThenElse ([ :len $Content ] > 0) \ ("Output:\n" . $Content) "No output available." ]) }); /file/remove "tmpfs/telegram-chat"; } else={ - $SendTelegram2 ({ origin=$0; silent=false; \ + $SendTelegram2 ({ origin=$0; chatid=$ChatID; silent=false; \ subject=([ $SymbolForNotification "speech-balloon" ] . "Telegram Chat"); \ message=("Command:\n" . $Text . "\n\nThe command failed syntax validation!") }); } -- cgit v1.2.3-70-g09d2