Skip to content

Commit

Permalink
Fix issue during the parsing of "badbins" (#66)
Browse files Browse the repository at this point in the history
* fix unpacking of what is actually a string

* update and run ruff
  • Loading branch information
AbstractUmbra authored Aug 1, 2024
1 parent 7c4770a commit 495fbd8
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 142 deletions.
5 changes: 1 addition & 4 deletions core/utils/paginator.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,7 @@ async def stop_pages(self, interaction: discord.Interaction | None = None) -> No
stop = stop_pages # type: ignore

def _check(self, interaction: discord.Interaction) -> bool:
if interaction.user.id != self.author.id:
return False

return True
return interaction.user.id == self.author.id

async def interaction_check(self, interaction: discord.Interaction) -> bool:
resp = self._check(interaction)
Expand Down
1 change: 1 addition & 0 deletions launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ async def main() -> None:
tasks.add(asyncio.create_task(bot.start(core.CONFIG["TOKENS"]["bot"])))
await server.serve()


try:
asyncio.run(main())
except KeyboardInterrupt:
Expand Down
5 changes: 1 addition & 4 deletions modules/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ def predicate(ctx: Context) -> bool:
if not isinstance(channel, discord.Thread):
return False

if channel.parent_id != Channels.HELP_FORUM:
return False

return True
return channel.parent_id == Channels.HELP_FORUM

return commands.check(predicate)

Expand Down
27 changes: 14 additions & 13 deletions modules/moderation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading

0 comments on commit 495fbd8

Please sign in to comment.