From: Carl Worth Date: Thu, 31 Dec 2020 21:51:33 +0000 (-0800) Subject: Rename local variable from item to puzzle X-Git-Url: https://git.cworth.org/git?p=turbot;a=commitdiff_plain;h=d9d496ec9103dc418270f4bbf5b9427bbb214465 Rename local variable from item to puzzle The overly-generic name here was not at at useful. With this specific name, the code will be much more clear when it says things like hunt['channel_id'] vs. puzzle['channel_id']. --- diff --git a/turbot/events.py b/turbot/events.py index 267d939..80fbaa0 100644 --- a/turbot/events.py +++ b/turbot/events.py @@ -221,30 +221,30 @@ def puzzle_channel_created(turb, channel_name, channel_id): .format(channel_id) + "Letting Slack retry this event") return lambda_error - item = response['Items'][0] + puzzle = response['Items'][0] - if 'sheet_url' in item: + if 'sheet_url' in puzzle: print("Info: channel_id {} already has sheet_url {}. Exiting." - .format(channel_id, item['sheet_url'])) + .format(channel_id, puzzle['sheet_url'])) return lambda_success # Before launching into sheet creation, indicate that we're doing this # in the database. This way, if we take too long to create the sheet # 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(channel_id) - turb.table.put_item(Item=item) + puzzle['sheet_url'] = 'pending' + puzzle['channel_url'] = channel_url(channel_id) + turb.table.put_item(Item=puzzle) # Create a sheet for the puzzle - sheet = sheets_create_for_puzzle(turb, item) + sheet = sheets_create_for_puzzle(turb, puzzle) # Update the database with the URL of the sheet - item['sheet_url'] = sheet['url'] - turb.table.put_item(Item=item) + puzzle['sheet_url'] = sheet['url'] + turb.table.put_item(Item=puzzle) # Get the new sheet_url into the channel description - set_channel_description(turb, item) + set_channel_description(turb, puzzle) # Lookup and invite all users from this hunt to this new puzzle # hunts_table = turb.db.Table('hunts') @@ -282,18 +282,18 @@ def puzzle_channel_created(turb, channel_name, channel_id): welcome_msg = ( "Welcome! This channel is the primary place to " + "discuss things as the team works together to solve the " - + "puzzle '{}'. ".format(item['name']) + + "puzzle '{}'. ".format(puzzle['name']) ) - if 'url' in item: + if 'url' in puzzle: welcome_msg += ( - "See the <{}|puzzle itself> ".format(item['url']) + "See the <{}|puzzle itself> ".format(puzzle['url']) + "for what was originally presented to us." ) sheet_msg = ( "Actual puzzle solving work will take place within the following " - + "<{}|shared spreadsheet> ".format(item['sheet_url']) + + "<{}|shared spreadsheet> ".format(puzzle['sheet_url']) ) state_msg = ( @@ -318,7 +318,7 @@ def puzzle_channel_created(turb, channel_name, channel_id): turb.slack_client.chat_postMessage( channel=channel_id, - text="New puzzle: {}".format(item['name']), + text="New puzzle: {}".format(['name']), blocks=[ section_block(text_block(welcome_msg)), section_block(text_block(sheet_msg)),