Skip to content

Commit 495fbd8

Browse files
Fix issue during the parsing of "badbins" (#66)
* fix unpacking of what is actually a string * update and run ruff
1 parent 7c4770a commit 495fbd8

File tree

6 files changed

+151
-142
lines changed

6 files changed

+151
-142
lines changed

core/utils/paginator.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,7 @@ async def stop_pages(self, interaction: discord.Interaction | None = None) -> No
237237
stop = stop_pages # type: ignore
238238

239239
def _check(self, interaction: discord.Interaction) -> bool:
240-
if interaction.user.id != self.author.id:
241-
return False
242-
243-
return True
240+
return interaction.user.id == self.author.id
244241

245242
async def interaction_check(self, interaction: discord.Interaction) -> bool:
246243
resp = self._check(interaction)

launcher.py

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ async def main() -> None:
7070
tasks.add(asyncio.create_task(bot.start(core.CONFIG["TOKENS"]["bot"])))
7171
await server.serve()
7272

73+
7374
try:
7475
asyncio.run(main())
7576
except KeyboardInterrupt:

modules/help.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,7 @@ def predicate(ctx: Context) -> bool:
7373
if not isinstance(channel, discord.Thread):
7474
return False
7575

76-
if channel.parent_id != Channels.HELP_FORUM:
77-
return False
78-
79-
return True
76+
return channel.parent_id == Channels.HELP_FORUM
8077

8178
return commands.check(predicate)
8279

modules/moderation.py

+14-13
Original file line numberDiff line numberDiff line change
@@ -243,25 +243,26 @@ async def post_mystbin_content(self, contents: list[tuple[str, str]]) -> str:
243243
async def find_badbins(self, message: discord.Message) -> None:
244244
matches = self.BADBIN_RE.findall(message.content)
245245

246-
if matches:
247-
contents: list[tuple[str, str]] = []
246+
if not matches:
247+
return
248+
249+
contents: list[tuple[str, str]] = []
248250

249-
for match in matches:
250-
site, slug, ext = match
251+
for match in matches:
252+
site, slug, ext = match
251253

252-
if site is None or slug is None:
253-
continue
254+
if site is None or slug is None:
255+
continue
254256

255-
contents.append((await self.pull_badbin_content(site, slug), f"migrated.{ext or 'txt'}"))
257+
contents.append((await self.pull_badbin_content(site, slug), f"migrated.{ext or 'txt'}"))
256258

257-
if contents:
258-
key, notice = await self.post_mystbin_content(contents)
259-
msg = f"I've detected a badbin and have uploaded your pastes here: https://mystb.in/{key}"
259+
if not contents:
260+
return
260261

261-
if notice:
262-
msg += "\nnotice: " + notice
262+
key = await self.post_mystbin_content(contents)
263+
msg = f"I've detected a badbin and have uploaded your pastes here: https://mystb.in/{key}"
263264

264-
await message.reply(msg, mention_author=False)
265+
await message.reply(msg, mention_author=False)
265266

266267
@commands.Cog.listener()
267268
async def on_papi_dpy_modlog(self, payload: ModLogPayload, /) -> None:

0 commit comments

Comments
 (0)