From b9a5884fd11246a8756a7d72baaa72efea0778b0 Mon Sep 17 00:00:00 2001 From: hibobmaster <32976627+hibobmaster@users.noreply.github.com> Date: Wed, 24 Apr 2024 18:33:03 +0800 Subject: [PATCH] Thread level chatting for Element Android --- src/bot.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/bot.py b/src/bot.py index 24cf640..953c972 100644 --- a/src/bot.py +++ b/src/bot.py @@ -290,6 +290,24 @@ async def message_callback(self, room: MatrixRoom, event: RoomMessageText) -> No ) except Exception as e: logger.error(e, exe_info=True) + # element android does not have m.mentions, we use another way to make it work + elif "formatted_body" in event_source["content"]: + if ( + self.user_id in event_source["content"]["formatted_body"] + and "m.relates_to" not in event_source["content"] + ): + try: + asyncio.create_task( + self.thread_chat( + room_id, + reply_to_event_id, + sender_id=sender_id, + thread_root_id=reply_to_event_id, + prompt=content_body, + ) + ) + except Exception as e: + logger.error(e, exe_info=True) # thread converstaion if "m.relates_to" in event_source["content"]: