from turbot.blocks import (
input_block, section_block, text_block, multi_select_block
)
-from turbot.hunt import find_hunt_for_hunt_id
+from turbot.hunt import find_hunt_for_hunt_id, hunt_blocks
from turbot.puzzle import find_puzzle_for_url
import turbot.rot
import turbot.sheets
return lambda_ok
commands["/solved"] = solved
+
+
+def hunt(turb, body, args):
+ """Implementation of the /hunt command
+
+ The (optional) args string should be one of 'all', 'solved', or
+ 'unsolved' to indicate which set of puzzles should be
+ displayed. If omitted, this command will default to showing only
+ unsolved puzzles.
+ """
+
+ channel_id = body['channel_id'][0]
+ response_url = body['response_url'][0]
+
+ hunt = hunt_for_channel(turb, channel_id)
+
+ if not hunt:
+ return bot_reply("Sorry, this channel doesn't appear to "
+ + "be a hunt or puzzle channel")
+
+ blocks = hunt_blocks(turb, hunt)
+
+ requests.post(response_url,
+ json = { 'blocks': blocks },
+ headers = {'Content-type': 'application/json'}
+ )
+
+ return lambda_ok
+
+commands["/hunt"] = hunt