From c5337f96a328952b42419aec170978b091c5812a Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sun, 9 Jun 2019 18:22:27 +0300 Subject: [PATCH] Add an option in events to make reply() act as respond() Should be a command handler argument or have some other way of making it configurable in the future. --- maubot/matrix.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/maubot/matrix.py b/maubot/matrix.py index c8e022b..914c58f 100644 --- a/maubot/matrix.py +++ b/maubot/matrix.py @@ -40,11 +40,13 @@ def parse_markdown(markdown: str, allow_html: bool = False) -> Tuple[str, str]: class MaubotMessageEvent(MessageEvent): client: MatrixClient + disable_reply: bool def __init__(self, base: MessageEvent, client: MatrixClient): super().__init__(**{a.name.lstrip("_"): getattr(base, a.name) for a in attr.fields(MessageEvent)}) self.client = client + self.disable_reply = False def respond(self, content: Union[str, MessageEventContent], event_type: EventType = EventType.ROOM_MESSAGE, markdown: bool = True, @@ -55,7 +57,7 @@ class MaubotMessageEvent(MessageEvent): content.format = Format.HTML content.body, content.formatted_body = parse_markdown(content.body, allow_html=html_in_markdown) - if reply: + if reply and not self.disable_reply: content.set_reply(self) return self.client.send_message_event(self.room_id, event_type, content)