From b0e0d226d51d1a881f8cf438c36a86fe457bdc92 Mon Sep 17 00:00:00 2001 From: Guillermo Rodriguez Date: Fri, 13 Oct 2023 22:40:38 -0300 Subject: [PATCH] Add reply thread response --- skynet/frontend/telegram/__init__.py | 4 +++- skynet/frontend/telegram/handlers.py | 18 ++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/skynet/frontend/telegram/__init__.py b/skynet/frontend/telegram/__init__.py index 14f8c6b..d4f1c49 100644 --- a/skynet/frontend/telegram/__init__.py +++ b/skynet/frontend/telegram/__init__.py @@ -305,6 +305,7 @@ class SkynetTelegramFrontend: parse_mode='HTML' ) ], + message_thread_id=status_msg.message_thread_id ) else: # txt2img @@ -313,7 +314,8 @@ class SkynetTelegramFrontend: caption=caption, photo=png_img, reply_markup=build_redo_menu(), - parse_mode='HTML' + parse_mode='HTML', + message_thread_id=status_msg.message_thread_id ) return True diff --git a/skynet/frontend/telegram/handlers.py b/skynet/frontend/telegram/handlers.py index ef0e31f..e4d31ca 100644 --- a/skynet/frontend/telegram/handlers.py +++ b/skynet/frontend/telegram/handlers.py @@ -129,7 +129,11 @@ def create_handler_context(frontend: 'SkynetTelegramFrontend'): # init new msg init_msg = 'started processing txt2img request...' - status_msg = await bot.reply_to(message, init_msg) + status_msg = await bot.reply_to( + message, + init_msg, + message_thread_id=message.message_thread_id + ) await db_call( 'new_user_request', user.id, message.id, status_msg.id, status=init_msg) @@ -191,7 +195,11 @@ def create_handler_context(frontend: 'SkynetTelegramFrontend'): # init new msg init_msg = 'started processing txt2img request...' - status_msg = await bot.reply_to(message, init_msg) + status_msg = await bot.reply_to( + message, + init_msg, + message_thread_id=message.message_thread_id + ) await db_call( 'new_user_request', user.id, message.id, status_msg.id, status=init_msg) @@ -282,10 +290,12 @@ def create_handler_context(frontend: 'SkynetTelegramFrontend'): init_msg = 'started processing redo request...' if is_query: - status_msg = await bot.send_message(chat.id, init_msg) + status_msg = await bot.send_message( + chat.id, init_msg, message_thread_id=message.message_thread_id) else: - status_msg = await bot.reply_to(message, init_msg) + status_msg = await bot.reply_to( + message, init_msg, message_thread_id=message.message_thread_id) method = await db_call('get_last_method_of', user.id) prompt = await db_call('get_last_prompt_of', user.id)