]> git.cworth.org Git - turbot/blobdiff - turbot/events.py
Add some links to the puzzle sheet when originally creating it
[turbot] / turbot / events.py
index 8a5119d53d9af3f2012e9bd435ab19b55a0b9b88..0a1eb099e8d3744782bd665be10f11ac03849799 100644 (file)
@@ -148,8 +148,8 @@ def hunt_channel_created(turb, channel_name, channel_id):
         "Welcome to the channel for the {} hunt! ".format(item['name'])
         + "Please wait a minute or two while I create some backend resources.")
 
-    # Create a sheet for the channel
-    sheet = turbot.sheets.sheets_create(turb, channel_name)
+    # Create a sheet for the hunt
+    sheet = turbot.sheets.sheets_create(turb, item['name'])
 
     # Update the database with the URL of the sheet
     item['sheet_url'] = sheet['url']
@@ -243,10 +243,11 @@ def puzzle_channel_created(turb, puzzle_channel_name, puzzle_channel_id):
     # and Slack retries the event, that next event will see this 'pending'
     # string and cleanly return (eliminating all future retries).
     item['sheet_url'] = 'pending'
+    item['channel_url'] = channel_url(puzzle_channel_id)
     puzzle_table.put_item(Item=item)
 
     # Create a sheet for the puzzle
-    sheet = turbot.sheets.sheets_create_for_puzzle(turb, puzzle_channel_name)
+    sheet = turbot.sheets.sheets_create_for_puzzle(turb, item)
 
     # Update the database with the URL of the sheet
     item['sheet_url'] = sheet['url']
@@ -255,6 +256,7 @@ def puzzle_channel_created(turb, puzzle_channel_name, puzzle_channel_id):
     # Get the new sheet_url into the channel description
     set_channel_description(turb, item)
 
+    # Finally, lookup and invite all users from this hunt to this new puzzle
     hunts_table = turb.db.Table('hunts')
     response = hunts_table.scan(
         FilterExpression='hunt_id = :hunt_id',
@@ -307,6 +309,4 @@ def channel_created(turb, event):
     else:
         return hunt_channel_created(turb, channel_name, channel_id)
 
-    
-
 events['channel_created'] = channel_created