From: Carl Worth <cworth@cworth.org>
Date: Sat, 9 Jan 2021 22:39:39 +0000 (-0800)
Subject: Fix to work with old puzzles that don't have a type attribute
X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=4778050b2bde391905712345b88f77616f4cc378;p=turbot

Fix to work with old puzzles that don't have a type attribute

Without this, commands like /state and /puzzle on old puzzle just die.
---

diff --git a/TODO b/TODO
index d0aa1ba..4aec8ea 100644
--- a/TODO
+++ b/TODO
@@ -1,5 +1,6 @@
 Bugs that we want to fix before Hunt 2021
 -----------------------------------------
+
 • Move sheets into a subfolder
 
 • Add "/hunt new"
@@ -9,6 +10,9 @@ Bugs that we want to fix before Hunt 2021
 Ordered punch-list (aiming to complete by 2021-01-08)
 -----------------------------------------------------
 
+• Add an "archive channel" button that is provided out after a puzzle
+  has been solved.
+
 • Add tags to the puzzle edit interface
 
 • Make the /hunt command drop from the database any rounds that have 0
diff --git a/turbot/interaction.py b/turbot/interaction.py
index 13b8ebf..f50a834 100644
--- a/turbot/interaction.py
+++ b/turbot/interaction.py
@@ -686,7 +686,7 @@ def puzzle(turb, body, args):
 
     # For a meta puzzle, also display the titles and solutions for all
     # puzzles in the same round.
-    if puzzle['type'] == 'meta':
+    if puzzle.get('type', 'plain') == 'meta':
         puzzles = hunt_puzzles_for_hunt_id(turb, puzzle['hunt_id'])
 
         # Drop this puzzle itself from the report
diff --git a/turbot/puzzle.py b/turbot/puzzle.py
index e1e1bc2..08e8621 100644
--- a/turbot/puzzle.py
+++ b/turbot/puzzle.py
@@ -247,7 +247,7 @@ def puzzle_channel_name(puzzle):
         round = '-' + puzzle_id_from_name(puzzle['rounds'][0])
 
     meta = ''
-    if puzzle['type'] == 'meta':
+    if puzzle.get('type', 'plain') == 'meta':
         meta = '-m'
 
     # Note: We don't use puzzle['puzzle_id'] here because we're keeping