)
import turbot.sheets
import turbot.slack
-from turbot.slack import slack_send_message
+from turbot.slack import slack_send_message, slack_channel_members
TURBOT_USER_ID = 'U01B9QM4P9R'
hunt_blocks = []
for hunt in hunts:
- if hunt['active']:
- hunt_blocks += hunt_block(turb, hunt)
+ if not hunt['active']:
+ continue
+ if user_id not in slack_channel_members(turb.slack_client,
+ hunt['channel_id']):
+ continue
+ hunt_blocks += hunt_block(turb, hunt)
return {
"type": "home",
"blocks": [
- section_block(text_block("*Active hunts*")),
+ section_block(text_block("*Hunts you belong to*")),
divider_block(),
* hunt_blocks,
actions_block(button_block("New hunt", "new_hunt"))
"Welcome to the channel for the {} hunt! ".format(item['name'])
+ "Please wait a minute or two while I create some backend resources.")
- # Create a sheet for the channel
- sheet = turbot.sheets.sheets_create(turb, channel_name)
+ # Create a sheet for the hunt
+ sheet = turbot.sheets.sheets_create(turb, item['name'])
# Update the database with the URL of the sheet
item['sheet_url'] = sheet['url']
# 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(puzzle_channel_id)
puzzle_table.put_item(Item=item)
# Create a sheet for the puzzle
- sheet = turbot.sheets.sheets_create_for_puzzle(turb, item['name'])
+ sheet = turbot.sheets.sheets_create_for_puzzle(turb, item)
# Update the database with the URL of the sheet
item['sheet_url'] = sheet['url']