-def channel_url(channel_id):
- return "https://halibutthatbass.slack.com/archives/{}".format(channel_id)
-
-def puzzle_block(puzzle):
- name = puzzle['name']
- status = puzzle['status']
- solution = puzzle['solution']
- channel_id = puzzle['channel_id']
- url = puzzle.get('url', None)
- sheet_url = puzzle.get('sheet_url', None)
- state = puzzle.get('state', None)
- status_emoji = ''
- solution_str = ''
-
- if status == 'solved':
- status_emoji = ":ballot_box_with_check:"
- else:
- status_emoji = ":white_square:"
-
- if len(solution):
- solution_str = "*`" + '`, `'.join(solution) + "`*"
-
- links = []
- if url:
- links.append("<{}|Puzzle>".format(url))
- if sheet_url:
- links.append("<{}|Sheet>".format(sheet_url))
-
- state_str = ''
- if state:
- state_str = "\n{}".format(state)
-
- puzzle_text = "{}{} <{}|{}> ({}){}".format(
- status_emoji, solution_str,
- channel_url(channel_id), name,
- ', '.join(links), state_str
- )
-
- return section_block(text_block(puzzle_text))