]> git.cworth.org Git - turbot/blobdiff - turbot/actions.py
Create a sheet for the hunt when creating a new hunt
[turbot] / turbot / actions.py
index 30ae6767d774a5a6268b8a795f1a714e2ce7aea2..b586d39048dab8942429d79bf3e5a6035b034f5c 100644 (file)
@@ -1,5 +1,6 @@
 from turbot.blocks import input_block
 import uuid
+import turbot.sheets
 
 def new_hunt(turb, payload):
     """Handler for the action of user pressing the new_hunt button"""
@@ -37,6 +38,7 @@ def new_hunt_submission(turb, payload):
     slug = state['slug']['slug']['value']
     url = state['url']['url']['value']
 
+    # Create a channel for the hunt
     response = turb.slack_client.conversations_create(name=slug)
 
     if not response['ok']:
@@ -49,6 +51,10 @@ def new_hunt_submission(turb, payload):
     user_id = payload['user']['id']
     channel_id = response['channel']['id']
 
+    # Create a sheet for the channel
+    sheet = turbot.sheets.sheets_create(turb, slug)
+
+    # Insert the newly-created hunt into the database
     turb.hunts_table = turb.db.Table("hunts")
     turb.hunts_table.put_item(
         Item={
@@ -60,6 +66,7 @@ def new_hunt_submission(turb, payload):
         }
     )
 
+    # Invite the initiating user to the channel
     turb.slack_client.conversations_invite(channel=channel_id, users=user_id)
 
     return {