From 9aaa2b31d2414278bc3a87e26b993e05742330fc Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Sun, 26 Jan 2025 15:56:28 -0800 Subject: [PATCH] TG reply in topics --- eve/api/api_requests.py | 1 + eve/clients/telegram/client.py | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/eve/api/api_requests.py b/eve/api/api_requests.py index 5b1a989..0ff7e55 100644 --- a/eve/api/api_requests.py +++ b/eve/api/api_requests.py @@ -23,6 +23,7 @@ class UpdateConfig(BaseModel): discord_channel_id: Optional[str] = None telegram_chat_id: Optional[str] = None telegram_message_id: Optional[str] = None + telegram_thread_id: Optional[str] = None cast_hash: Optional[str] = None author_fid: Optional[int] = None message_id: Optional[str] = None diff --git a/eve/clients/telegram/client.py b/eve/clients/telegram/client.py index 7c649b1..bc61dbd 100644 --- a/eve/clients/telegram/client.py +++ b/eve/clients/telegram/client.py @@ -203,6 +203,7 @@ async def async_callback(message): update_config = data.get("update_config", {}) telegram_chat_id = update_config.get("telegram_chat_id") telegram_message_id = update_config.get("telegram_message_id") + telegram_thread_id = update_config.get("telegram_thread_id") if not telegram_chat_id: print("No telegram_chat_id in update_config:", data) @@ -230,6 +231,7 @@ async def async_callback(message): chat_id=telegram_chat_id, text=content, reply_to_message_id=telegram_message_id, + message_thread_id=telegram_thread_id, ) elif update_type == UpdateType.TOOL_COMPLETE: @@ -247,12 +249,14 @@ async def async_callback(message): chat_id=telegram_chat_id, video=url, reply_to_message_id=telegram_message_id, + message_thread_id=telegram_thread_id, ) else: await application.bot.send_photo( chat_id=telegram_chat_id, photo=url, reply_to_message_id=telegram_message_id, + message_thread_id=telegram_thread_id, ) elif update_type == UpdateType.END_PROMPT: @@ -382,6 +386,9 @@ async def echo(self, update: Update, context: ContextTypes.DEFAULT_TYPE): "sub_channel_name": self.channel_name, "telegram_chat_id": str(chat_id), "telegram_message_id": str(message.message_id), + "telegram_thread_id": str(message_thread_id) + if message_thread_id + else None, }, }