]> git.cworth.org Git - turbot/commitdiff
Fix bug that was causing a dispatch_failed on /puzzle in a non-puzzle channel
authorCarl Worth <cworth@cworth.org>
Fri, 23 Oct 2020 00:47:21 +0000 (17:47 -0700)
committerCarl Worth <cworth@cworth.org>
Fri, 23 Oct 2020 00:55:01 +0000 (17:55 -0700)
This was some return-type mismatch and other breakage from recent
reworking of channel_is_hunt.

turbot/interaction.py

index 20b2d7db820df0fd7b7a3242cc2e215e769cf26e..1638b7391eac709d42a84cd40192056d8cc4b777 100644 (file)
@@ -211,7 +211,7 @@ def get_table_item(turb, table_name, key, value):
     if 'Item' in response:
         return (response['Item'], table)
     else:
-        return None
+        return (None, None)
 
 def channel_is_puzzle(turb, channel_id, channel_name):
     """Given a channel ID/name return the database item for the puzzle
@@ -251,7 +251,7 @@ def find_hunt_for_channel(turb, channel_id, channel_name):
 
     Returns a tuple of (hunt_name, hunt_id) or (None, None)."""
 
-    (hunt, hunts_table) = channel_is_hunt(turb, channel_id)
+    (hunt, _) = channel_is_hunt(turb, channel_id)
 
     if hunt:
         return (hunt['hunt_id'], hunt['name'])
@@ -260,12 +260,14 @@ def find_hunt_for_channel(turb, channel_id, channel_name):
     # puzzle channel with a hunt-id prefix.
     hunt_id = channel_name.split('-')[0]
 
+    hunts_table = turb.db.Table("hunts")
+
     response = hunts_table.scan(
         FilterExpression='hunt_id = :hunt_id',
         ExpressionAttributeValues={':hunt_id': hunt_id}
     )
 
-    if 'Items' in response:
+    if 'Items' in response and len(response['Items']):
         item = response['Items'][0]
         return (item['hunt_id'], item['name'])