Skip to content

Commit

Permalink
allow spoiler around fmc solution submissions
Browse files Browse the repository at this point in the history
  • Loading branch information
benwh1 committed Aug 31, 2021
1 parent e2c5d07 commit e589939
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,18 @@ async def on_message(message):
return
try:
await message.delete()
solution = Algorithm(command[8:])

# !submit [solution, optionally spoilered]
solution_reg = regex.optionally_spoilered(regex.algorithm("solution"))
reg = re.compile(f"!submit\s+{solution_reg}")
match = reg.fullmatch(command)

if match is None:
raise SyntaxError(f"failed to read solution")

groups = match.groupdict()

solution = Algorithm(groups["solution"])
await fmc.submit(message.author, solution)
except Exception as e:
traceback.print_exc()
Expand Down

0 comments on commit e589939

Please sign in to comment.