From 6f0c85d45a8e9d0f4d8105e356e82a0efa3691f1 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 22 Oct 2020 17:40:43 -0700 Subject: [PATCH] Add an implementation of the /solved command For marking a known solution to a puzzle. --- turbot/interaction.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/turbot/interaction.py b/turbot/interaction.py index cb69467..20b2d7d 100644 --- a/turbot/interaction.py +++ b/turbot/interaction.py @@ -411,3 +411,25 @@ def state(turb, body, args): 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 -- 2.43.0