From 1859c095ea436c32e8fba9bff01c09a22c7baf28 Mon Sep 17 00:00:00 2001 From: witchent Date: Wed, 14 Oct 2020 22:06:49 +0000 Subject: [PATCH] Use portals main_intent if possible But check for bridge bot in replies. --- mautrix/bridge/commands/handler.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mautrix/bridge/commands/handler.py b/mautrix/bridge/commands/handler.py index 21fe13a0..ae9b046c 100644 --- a/mautrix/bridge/commands/handler.py +++ b/mautrix/bridge/commands/handler.py @@ -128,7 +128,7 @@ def print_error_traceback(self) -> bool: @property def main_intent(self) -> IntentAPI: - return (self.portal.main_intent if self.portal and not self.has_bridge_bot + return (self.portal.main_intent if self.portal else self.az.intent) def reply(self, message: str, allow_html: bool = False, render_markdown: bool = True @@ -154,7 +154,10 @@ def reply(self, message: str, allow_html: bool = False, render_markdown: bool = message = self._replace_command_prefix(message) html = self._render_message(message, allow_html=allow_html, render_markdown=render_markdown) - return self.main_intent.send_notice(self.room_id, message, html=html) + if self.has_bridge_bot: + return self.az.intent.send_notice(self.room_id, message, html=html) + else: + return self.main_intent.send_notice(self.room_id, message, html=html) def mark_read(self) -> Awaitable[None]: """Marks the command as read by the bot."""