Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue during the parsing of "badbins" #66

Merged
merged 2 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading