spoiler
This commit is contained in:
parent
e8482b8d3e
commit
dc8d45818e
1 changed files with 14 additions and 8 deletions
16
main.py
16
main.py
|
@ -113,15 +113,21 @@ class MatrixClient(nio.AsyncClient):
|
|||
return resp.content_uri
|
||||
|
||||
async def get_fmt_body(self, body, emotes):
|
||||
# Markdown code blocks
|
||||
replace = "```"
|
||||
for i in range(body.count(replace)):
|
||||
replace_ = [
|
||||
# Code blocks
|
||||
("```", "<pre><code>", "</code></pre>"),
|
||||
# Spoilers
|
||||
("||", "<span data-mx-spoiler>", "</span>")
|
||||
]
|
||||
|
||||
for replace in replace_:
|
||||
for i in range(body.count(replace[0])):
|
||||
i += 1
|
||||
|
||||
if i % 2:
|
||||
body = body.replace(replace, "<pre><code>", 1)
|
||||
body = body.replace(replace[0], replace[1], 1)
|
||||
else:
|
||||
body = body.replace(replace, "</code></pre>", 1)
|
||||
body = body.replace(replace[0], replace[2], 1)
|
||||
|
||||
for emote in emotes.keys():
|
||||
emote_ = await self.upload_emote(emotes[emote])
|
||||
|
|
Loading…
Reference in a new issue