X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=turbot%2Finteraction.py;h=1638b7391eac709d42a84cd40192056d8cc4b777;hb=c74c04333d2d40c6421a1561d1ce8844129c96d7;hp=20b2d7db820df0fd7b7a3242cc2e215e769cf26e;hpb=6f0c85d45a8e9d0f4d8105e356e82a0efa3691f1;p=turbot 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'])