So that people can easily find active, public hunts.
return section_block(text_block(puzzle_text))
return section_block(text_block(puzzle_text))
-def hunt_block(turb, hunt):
+def hunt_details_block(turb, hunt):
name = hunt['name']
hunt_id = hunt['hunt_id']
channel_id = hunt['channel_id']
name = hunt['name']
hunt_id = hunt['hunt_id']
channel_id = hunt['channel_id']
+def available_hunt_block(turb, hunt):
+
+ name = hunt['name']
+ channel_id = hunt['channel_id']
+
+ hunt_link = "*<{}|{}>*".format(channel_url(channel_id), name)
+
+ return [
+ section_block(text_block(hunt_link)),
+ ]
+
def home(turb, user_id):
"""Returns a view to be published as the turbot home tab for user_id
def home(turb, user_id):
"""Returns a view to be published as the turbot home tab for user_id
except Exception:
hunts = []
except Exception:
hunts = []
+ my_hunt_blocks = []
+ available_hunt_blocks = []
for hunt in hunts:
if not hunt['active']:
continue
for hunt in hunts:
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)
-
- if len(hunt_blocks):
- hunt_blocks = [
- section_block(text_block("*Hunts you belong to*")),
+ if user_id in slack_channel_members(turb.slack_client,
+ hunt['channel_id']):
+ my_hunt_blocks += hunt_details_block(turb, hunt)
+ else:
+ available_hunt_blocks += available_hunt_block(turb, hunt)
+
+ if len(my_hunt_blocks):
+ my_hunt_blocks = [
+ section_block(text_block("*Hunts you belong to:*")),
section_block(text_block("You do not belong to any hunts"))
]
section_block(text_block("You do not belong to any hunts"))
]
+ if len(available_hunt_blocks):
+ available_hunt_blocks = [
+ section_block(text_block("*Hunts you can join:*")),
+ divider_block(),
+ * available_hunt_blocks
+ ]
+
return {
"type": "home",
"blocks": [
return {
"type": "home",
"blocks": [
+ * my_hunt_blocks,
+ * available_hunt_blocks,
actions_block(button_block("New hunt", "new_hunt"))
]
}
actions_block(button_block("New hunt", "new_hunt"))
]
}