Add fallback stuff for replies

This commit is contained in:
git-bruh 2020-11-30 20:44:17 +05:30
parent 715b987444
commit f21d6b8da7
No known key found for this signature in database
GPG key ID: E1475C50075ADCE6

14
main.py
View file

@ -78,10 +78,24 @@ class MatrixClient(object):
}
if reply_id:
reply_event = await matrix_client.room_get_event(
config["room_id"], reply_id
)
reply_event = reply_event.event.source["content"]["body"]
content["m.relates_to"] = {
"m.in_reply_to": {"event_id": reply_id},
}
content["format"] = "org.matrix.custom.html"
content["formatted_body"] = (f"""<mx-reply><blockquote>
<a href="https://matrix.to/#/{config["room_id"]}/{reply_id}">In reply to</a>
<a href="https://matrix.to/#/{config["username"]}">{config["username"]}</a><br>
{reply_event}</blockquote></mx-reply>{message}
""")
if edit_id:
content["body"] = f" * {message}"