From 71a48f309ab92b3998ef302f7326b8bb90315ab1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20N=C3=B8rgaard?= Date: Wed, 31 Jul 2024 22:43:17 +0100 Subject: [PATCH] fix unpacking of what is actually a string --- modules/moderation.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/modules/moderation.py b/modules/moderation.py index fae315d..fe8db97 100644 --- a/modules/moderation.py +++ b/modules/moderation.py @@ -243,25 +243,26 @@ async def post_mystbin_content(self, contents: list[tuple[str, str]]) -> str: async def find_badbins(self, message: discord.Message) -> None: matches = self.BADBIN_RE.findall(message.content) - if matches: - contents: list[tuple[str, str]] = [] + if not matches: + return + + contents: list[tuple[str, str]] = [] - for match in matches: - site, slug, ext = match + for match in matches: + site, slug, ext = match - if site is None or slug is None: - continue + if site is None or slug is None: + continue - contents.append((await self.pull_badbin_content(site, slug), f"migrated.{ext or 'txt'}")) + contents.append((await self.pull_badbin_content(site, slug), f"migrated.{ext or 'txt'}")) - if contents: - key, notice = await self.post_mystbin_content(contents) - msg = f"I've detected a badbin and have uploaded your pastes here: https://mystb.in/{key}" + if not contents: + return - if notice: - msg += "\nnotice: " + notice + key = await self.post_mystbin_content(contents) + msg = f"I've detected a badbin and have uploaded your pastes here: https://mystb.in/{key}" - await message.reply(msg, mention_author=False) + await message.reply(msg, mention_author=False) @commands.Cog.listener() async def on_papi_dpy_modlog(self, payload: ModLogPayload, /) -> None: