Skip to content

Commit

Permalink
Merge pull request #33 from sigpwny/duplicate-chals
Browse files Browse the repository at this point in the history
better duplicate challenge detection
  • Loading branch information
user32121 authored Oct 5, 2024
2 parents c6ddd41 + 9f6108c commit 0642d3f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/cogs/chal/chal.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ async def create(self, ctx: SlashContext, name: str, category: str) -> None:
await ctx.send(":x: Unsolved cannot be a category.")
return
for post in forum.get_posts(exclude_archived=False):
if ((post.name or "") == name):
await ctx.send(f":x: Challenge {name} already exists.")
post_name = post.name or ""
# remove solved prefix
if (post_name.startswith("✔-")):
post_name = post_name[len("✔-"):]
if (post_name.lower() == name.lower()):
await ctx.send(f":x: Challenge {post.mention} already exists.")
return

# check valid category
Expand Down

0 comments on commit 0642d3f

Please sign in to comment.