.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')
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 = (
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)),