spoiler
This commit is contained in:
parent
e8482b8d3e
commit
dc8d45818e
1 changed files with 14 additions and 8 deletions
22
main.py
22
main.py
|
@ -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])
|
||||||
|
|
Loading…
Reference in a new issue