don't send formatted body needlessly

This commit is contained in:
git-bruh 2021-07-19 17:17:04 +05:30
parent 3b47e5af3f
commit 597c82cd88
No known key found for this signature in database
GPG key ID: E1475C50075ADCE6

View file

@ -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</a><a href="https://matrix.to/#/{event.sender}">\
return content
def get_fmt(self, message: str, emotes: dict) -> str:
message = markdown.markdown(message)
message = (
markdown.markdown(message).replace("<p>", "").replace("</p>", "")
)
# Upload emotes in multiple threads so that we don't
# block the Discord bot for too long.