"Sorry, this channel doesn't appear to be a hunt or a puzzle "
+ "channel, so the `/puzzle` command cannot work here.")
- blocks = puzzle_blocks(puzzle)
+ blocks = puzzle_blocks(puzzle, include_rounds=True)
requests.post(response_url,
json = {'blocks': blocks},
return response['Items'][0]
-def puzzle_blocks(puzzle):
+def puzzle_blocks(puzzle, include_rounds=False):
"""Generate Slack blocks for a puzzle
The puzzle argument should be a dictionary as returned from the
if state:
state_str = "\n{}".format(state)
- puzzle_text = "{}{} <{}|{}> ({}){}".format(
+ rounds_str = ''
+ if include_rounds and 'rounds' in puzzle:
+ rounds = puzzle['rounds']
+ rounds_str = " in round{}: {}".format(
+ "s" if len(rounds) > 1 else "",
+ ", ".join(rounds)
+ )
+
+ puzzle_text = "{}{} <{}|{}> ({}){}{}".format(
status_emoji, solution_str,
channel_url(channel_id), name,
- ', '.join(links), state_str
+ ', '.join(links), rounds_str,
+ state_str
)
# Combining hunt ID and puzzle ID together here is safe because