don't send formatted body needlessly
This commit is contained in:
parent
3b47e5af3f
commit
597c82cd88
1 changed files with 12 additions and 3 deletions
|
@ -211,11 +211,18 @@ class MatrixClient(AppService):
|
||||||
) -> dict:
|
) -> dict:
|
||||||
content = {
|
content = {
|
||||||
"body": message,
|
"body": message,
|
||||||
"format": "org.matrix.custom.html",
|
|
||||||
"msgtype": "m.text",
|
"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
|
ref_id = None
|
||||||
|
|
||||||
if reference:
|
if reference:
|
||||||
|
@ -282,7 +289,9 @@ In reply to</a><a href="https://matrix.to/#/{event.sender}">\
|
||||||
return content
|
return content
|
||||||
|
|
||||||
def get_fmt(self, message: str, emotes: dict) -> str:
|
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
|
# Upload emotes in multiple threads so that we don't
|
||||||
# block the Discord bot for too long.
|
# block the Discord bot for too long.
|
||||||
|
|
Loading…
Reference in a new issue