]> git.cworth.org Git - turbot/commitdiff
Append "-solved" to puzzle channel names when /solved
authorjustin melvin <jmelvinprime@gmail.com>
Sat, 28 Nov 2020 06:49:59 +0000 (22:49 -0800)
committerjustin melvin <jmelvinprime@gmail.com>
Sat, 28 Nov 2020 06:49:59 +0000 (22:49 -0800)
turbot/interaction.py

index a3bfea0a5281176ea6eb316516778e151749d219..1c5b34ec620c5a616f6472d539d30243b076afb6 100644 (file)
@@ -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