diff --git a/appservice/main.py b/appservice/main.py index edf4bb0..5155fcd 100644 --- a/appservice/main.py +++ b/appservice/main.py @@ -211,11 +211,18 @@ class MatrixClient(AppService): ) -> dict: content = { "body": message, - "format": "org.matrix.custom.html", "msgtype": "m.text", - "formatted_body": self.get_fmt(message, emotes), } + fmt = self.get_fmt(message, emotes) + + if len(fmt) != len(message): + content = { + **content, + "format": "org.matrix.custom.html", + "formatted_body": fmt, + } + ref_id = None if reference: @@ -282,7 +289,9 @@ In reply to\ return content def get_fmt(self, message: str, emotes: dict) -> str: - message = markdown.markdown(message) + message = ( + markdown.markdown(message).replace("

", "").replace("

", "") + ) # Upload emotes in multiple threads so that we don't # block the Discord bot for too long.