From: justin melvin Date: Sat, 28 Nov 2020 06:49:59 +0000 (-0800) Subject: Append "-solved" to puzzle channel names when /solved X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=f2d1e77569336da5cae322ced59a002555a42d5d;hp=73a9b7caa6d0ade5d107453b50d2ddd0ad28cb20;p=turbot Append "-solved" to puzzle channel names when /solved --- diff --git a/turbot/interaction.py b/turbot/interaction.py index a3bfea0..1c5b34e 100644 --- a/turbot/interaction.py +++ b/turbot/interaction.py @@ -352,6 +352,7 @@ def puzzle_submission(turb, payload, metadata): table.put_item( Item={ "channel_id": puzzle_channel_id, + "orig_channel_name": hunt_dash_channel, "solution": [], "status": 'unsolved', "name": name, @@ -362,6 +363,13 @@ def puzzle_submission(turb, payload, metadata): return lambda_ok +def rename_channel_to_solved(turb, puzzle): + orig_channel_name = puzzle['orig_channel_name'] + channel_id = puzzle['channel_id'] + newName = orig_channel_name + '-solved' + turb.slack_client.conversations_rename(channel=channel_id, + name=newName) + # XXX: This duplicates functionality eith events.py:set_channel_description def set_channel_topic(turb, puzzle): channel_id = puzzle['channel_id'] @@ -447,6 +455,9 @@ def solved(turb, body, args): # And rename the sheet to prefix with SOLVED - turbot.sheets.renameSheet(turb, puzzle['sheet_url'], 'SOLVED - ' + puzzle['name']) + # Finally, rename the Slack channel to add the suffix '-solved' + rename_channel_to_solved(turb, puzzle) + return lambda_ok commands["/solved"] = solved