- return bot_reply("Unknown syntax for `/puzzle` command. " +
- "Use `/puzzle new` to create a new puzzle.")
+ if len(args):
+ return bot_reply("Unknown syntax for `/puzzle` command. " +
+ "Use `/puzzle new` to create a new puzzle.")
+
+ # For no arguments we print the current puzzle as a reply
+ channel_id = body['channel_id'][0]
+ response_url = body['response_url'][0]
+
+ puzzle = puzzle_for_channel(turb, channel_id)
+
+ if not puzzle:
+ hunt = hunt_for_channel(turb, channel_id)
+ if hunt:
+ return bot_reply(
+ "This is not a puzzle channel, but is a hunt channel. "
+ + "If you want to create a new puzzle for this hunt, use "
+ + "`/puzzle new`.")
+ else:
+ return bot_reply(
+ "Sorry, this channel doesn't appear to be a hunt or a puzzle "
+ + "channel, so the `/puzzle` command cannot work here.")
+
+ blocks = puzzle_blocks(puzzle)
+
+ requests.post(response_url,
+ json = {'blocks': blocks},
+ headers = {'Content-type': 'application/json'}
+ )
+
+ return lambda_ok