1 from turbot.blocks import (
2 section_block, text_block, button_block, actions_block
7 channel_id = hunt['channel_id']
9 text = "{}: ".format(name)
11 if (channel_id.startswith("placeholder-")):
12 text += "[Slack channel is still being created. Please wait.]"
14 text += "<#{}>".format(channel_id)
16 return section_block(text_block(text))
18 def home(turb, user_id, body):
19 """Returns a view to be published as the turbot home tab for user_id
21 The body argument is a dictionary as provided by the Slack request.
22 The return value is a dictionary suitable to be published to the
23 Slack views_publish API."""
25 response = turb.db.Table("hunts").scan()
26 hunts = response['Items']
31 section_block(text_block("*Active hunts*")),
32 *[hunt_block(hunt) for hunt in hunts if hunt['active']],
33 actions_block(button_block("New hunt", "new_hunt"))
37 def app_home_opened(turb, body):
38 user_id = body['event']['user']
39 view = home(turb, user_id, body)
40 turb.slack_client.views_publish(user_id=user_id, view=view)
44 "app_home_opened": app_home_opened