-# XXX: This duplicates functionality eith events.py:set_channel_description
-def set_channel_topic(turb, puzzle):
- channel_id = puzzle['channel_id']
- name = puzzle['name']
- url = puzzle.get('url', None)
- sheet_url = puzzle.get('sheet_url', None)
- state = puzzle.get('state', None)
- status = puzzle['status']
-
- description = ''
-
- if status == 'solved':
- description += "SOLVED: `{}` ".format('`, `'.join(puzzle['solution']))
-
- description += name
-
- links = []
- if url:
- links.append("<{}|Puzzle>".format(url))
- if sheet_url:
- links.append("<{}|Sheet>".format(sheet_url))
-
- if len(links):
- description += "({})".format(', '.join(links))
-
- if state:
- description += " {}".format(state)
-
- # Slack only allows 250 characters for a topic
- if len(description) > 250:
- description = description[:247] + "..."
-
- turb.slack_client.conversations_setTopic(channel=channel_id,
- topic=description)
-