This commit is contained in:
git-bruh 2021-01-15 16:51:04 +05:30
parent e8482b8d3e
commit dc8d45818e
No known key found for this signature in database
GPG key ID: E1475C50075ADCE6

22
main.py
View file

@ -113,15 +113,21 @@ class MatrixClient(nio.AsyncClient):
return resp.content_uri return resp.content_uri
async def get_fmt_body(self, body, emotes): async def get_fmt_body(self, body, emotes):
# Markdown code blocks replace_ = [
replace = "```" # Code blocks
for i in range(body.count(replace)): ("```", "<pre><code>", "</code></pre>"),
i += 1 # Spoilers
("||", "<span data-mx-spoiler>", "</span>")
]
if i % 2: for replace in replace_:
body = body.replace(replace, "<pre><code>", 1) for i in range(body.count(replace[0])):
else: i += 1
body = body.replace(replace, "</code></pre>", 1)
if i % 2:
body = body.replace(replace[0], replace[1], 1)
else:
body = body.replace(replace[0], replace[2], 1)
for emote in emotes.keys(): for emote in emotes.keys():
emote_ = await self.upload_emote(emotes[emote]) emote_ = await self.upload_emote(emotes[emote])