From f0e2bb3d628cffa5a254d445dea894cfd0bdcf49 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Tue, 31 Jan 2023 16:35:56 +0200 Subject: [PATCH] Add option to use thread for replies --- maubot/matrix.py | 11 ++++++++++- requirements.txt | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/maubot/matrix.py b/maubot/matrix.py index a66ebfe..31efdfc 100644 --- a/maubot/matrix.py +++ b/maubot/matrix.py @@ -82,6 +82,7 @@ class MaubotMessageEvent(MessageEvent): markdown: bool = True, allow_html: bool = False, reply: bool | str = False, + reply_in_thread: bool = False, edits: EventID | MessageEvent | None = None, ) -> EventID: if isinstance(content, str): @@ -102,6 +103,8 @@ class MaubotMessageEvent(MessageEvent): f"{self.sender}" f": {fmt_body}" ) + elif reply_in_thread: + content.set_thread_parent(self) else: content.set_reply(self) return await self.client.send_message_event(self.room_id, event_type, content) @@ -112,9 +115,15 @@ class MaubotMessageEvent(MessageEvent): event_type: EventType = EventType.ROOM_MESSAGE, markdown: bool = True, allow_html: bool = False, + thread: bool = False, ) -> Awaitable[EventID]: return self.respond( - content, event_type, markdown=markdown, reply=True, allow_html=allow_html + content, + event_type, + markdown=markdown, + reply=True, + reply_in_thread=thread, + allow_html=allow_html, ) def mark_read(self) -> Awaitable[None]: diff --git a/requirements.txt b/requirements.txt index d050f78..c0cada8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -mautrix>=0.15.5,<0.19 +mautrix>=0.16.2,<0.20 aiohttp>=3,<4 yarl>=1,<2 SQLAlchemy>=1,<1.4