Add option to use thread for replies

This commit is contained in:
Tulir Asokan 2023-01-31 16:35:56 +02:00
parent bf3a3b65d8
commit f0e2bb3d62
2 changed files with 11 additions and 2 deletions

View file

@ -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"</a>: {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]:

View file

@ -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