From c74c04333d2d40c6421a1561d1ce8844129c96d7 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 22 Oct 2020 17:47:21 -0700 Subject: [PATCH] Fix bug that was causing a dispatch_failed on /puzzle in a non-puzzle channel This was some return-type mismatch and other breakage from recent reworking of channel_is_hunt. --- turbot/interaction.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/turbot/interaction.py b/turbot/interaction.py index 20b2d7d..1638b73 100644 --- a/turbot/interaction.py +++ b/turbot/interaction.py @@ -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']) -- 2.43.0