return lambda_success
+def set_channel_description(turb, puzzle):
+ channel_id = puzzle['channel_id']
+ description = puzzle['name']
+ url = puzzle.get('url', None)
+ sheet_url = puzzle.get('sheet_url', None)
+
+ links = []
+ if url:
+ links.append("<{}|Puzzle>".format(url))
+ if sheet_url:
+ links.append("<{}|Sheet>".format(sheet_url))
+
+ if len(links):
+ description += "({})".format(', '.join(links))
+
+ turb.slack_client.conversations_setPurpose(channel=channel_id,
+ purpose=description)
+ turb.slack_client.conversations_setTopic(channel=channel_id,
+ topic=description)
+
def puzzle_channel_created(turb, puzzle_channel_name, puzzle_channel_id):
"""Creates sheet and invites user for a newly-created puzzle channel"""
if not item['url']:
del item['url']
+ # Get the puzzle's name into the channel description
+ set_channel_description(turb, item)
+
# Before launching into sheet creation, indicate that we're doing this
# in the database. This way, if we take too long to create the sheet
# and Slack retries the event, that next event will see this 'pending'
text="Sheet created for this puzzle: {}"
.format(sheet['url']))
+ # Get the new sheet_url into the channel description
+ set_channel_description(turb, item)
+
hunts_table = turb.db.Table('hunts')
response = hunts_table.scan(
FilterExpression='hunt_id = :hunt_id',