Using the slug of the hunt for the channel name.
Some thoughts on improving this:
* Should we modify the slug in some way to distinguish this as a
hunt channel?
* We should definitely do validation of the legality of the slug for
a channel name.
* We should invite the triggering user to the channel
* We should put the hunt URL into the topic or description
* Do we want to create a sheet for hunt channels or only for puzzle
channels?
slug = state['slug']['slug']['value']
url = state['url']['url']['value']
- table = turb.db.Table("hunts")
- table.put_item(
+ response = turb.slack_client.conversations_create(name=slug)
+
+ if not response['ok']:
+ print("Error creating channel for hunt {}: {}"
+ .format(name, str(response)))
+ return {
+ 'statusCode': 400
+ }
+
+ channel_id = response['channel']['id']
+
+ turb.hunts_table = turb.db.Table("hunts")
+ turb.hunts_table.put_item(
Item={
- 'channel_id': "placeholder-" + str(uuid.uuid4()),
+ 'channel_id': channel_id,
"active": True,
"name": name,
"slug": slug,