From dc8d45818eaf4fd19eabe2d243c499a97a6e3f51 Mon Sep 17 00:00:00 2001 From: git-bruh Date: Fri, 15 Jan 2021 16:51:04 +0530 Subject: [PATCH] spoiler --- main.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/main.py b/main.py index c0b358a..87097f6 100644 --- a/main.py +++ b/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)): - i += 1 + replace_ = [ + # Code blocks + ("```", "
", "
"), + # Spoilers + ("||", "", "") + ] - if i % 2: - body = body.replace(replace, "
", 1)
-            else:
-                body = body.replace(replace, "
", 1) + for replace in replace_: + for i in range(body.count(replace[0])): + i += 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(): emote_ = await self.upload_emote(emotes[emote])