+ return lambda_ok
+
+# XXX: This duplicates functionality eith events.py:set_channel_description
+def set_channel_topic(turb, puzzle):
+ channel_id = puzzle['channel_id']
+ description = puzzle['name']
+ url = puzzle.get('url', None)
+ sheet_url = puzzle.get('sheet_url', None)
+ state = puzzle.get('state', None)
+
+ links = []
+ if url:
+ links.append("<{}|Puzzle>".format(url))
+ if sheet_url:
+ links.append("<{}|Sheet>".format(sheet_url))
+
+ if len(links):
+ description += "({})".format(', '.join(links))
+
+ if state:
+ description += " {}".format(state)
+
+ turb.slack_client.conversations_setTopic(channel=channel_id,
+ topic=description)
+
+def state(turb, body, args):
+ """Implementation of the /state command
+
+ The args string should be a brief sentence describing where things
+ stand or what's needed."""
+
+ channel_id = body['channel_id'][0]
+ channel_name = body['channel_name'][0]
+
+ (puzzle, table) = channel_is_puzzle(turb, channel_id, channel_name)
+
+ if not puzzle:
+ return bot_reply("Sorry, this is not a puzzle channel.")
+
+ # Set the state field in the database
+ puzzle['state'] = args
+ table.put_item(Item=puzzle)
+
+ set_channel_topic(turb, puzzle)
+
+ return lambda_ok
+
+commands["/state"] = state
+
+def solved(turb, body, args):
+ """Implementation of the /solved command
+
+ The args string should be a confirmed solution."""
+
+ channel_id = body['channel_id'][0]
+ channel_name = body['channel_name'][0]
+
+ (puzzle, table) = channel_is_puzzle(turb, channel_id, channel_name)
+
+ if not puzzle:
+ return bot_reply("Sorry, this is not a puzzle channel.")
+
+ # Set the status and solution fields in the database
+ puzzle['status'] = 'solved'
+ puzzle['solution'].append(args)
+ table.put_item(Item=puzzle)
+
+ return lambda_ok
+
+commands["/solved"] = solved