From 597c82cd886852cdba33eee41728d50c72a6c58b Mon Sep 17 00:00:00 2001 From: git-bruh Date: Mon, 19 Jul 2021 17:17:04 +0530 Subject: [PATCH] don't send formatted body needlessly --- appservice/main.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) 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.