From 401643afba79b42e1454a0ba406d9e416985e8c5 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Mon, 7 Jan 2019 09:05:47 +0200 Subject: [PATCH] Add html_in_markdown option to reply() and respond() --- maubot/matrix.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/maubot/matrix.py b/maubot/matrix.py index 1cb2d6e..fb972e2 100644 --- a/maubot/matrix.py +++ b/maubot/matrix.py @@ -47,21 +47,23 @@ class MaubotMessageEvent(MessageEvent): self.client = client def respond(self, content: Union[str, MessageEventContent], - event_type: EventType = EventType.ROOM_MESSAGE, - markdown: bool = True, reply: bool = False) -> Awaitable[EventID]: + event_type: EventType = EventType.ROOM_MESSAGE, markdown: bool = True, + html_in_markdown: bool = False, reply: bool = False) -> Awaitable[EventID]: if isinstance(content, str): content = TextMessageEventContent(msgtype=MessageType.NOTICE, body=content) if markdown: content.format = Format.HTML - content.body, content.formatted_body = parse_markdown(content.body) + content.body, content.formatted_body = parse_markdown(content.body, + allow_html=html_in_markdown) if reply: content.set_reply(self) return self.client.send_message_event(self.room_id, event_type, content) def reply(self, content: Union[str, MessageEventContent], - event_type: EventType = EventType.ROOM_MESSAGE, - markdown: bool = True) -> Awaitable[EventID]: - return self.respond(content, event_type, markdown, reply=True) + event_type: EventType = EventType.ROOM_MESSAGE, markdown: bool = True, + html_in_markdown: bool = False) -> Awaitable[EventID]: + return self.respond(content, event_type, markdown, reply=True, + html_in_markdown=html_in_markdown) def mark_read(self) -> Awaitable[None]: return self.client.send_receipt(self.room_id, self.event_id, "m.read")