]> git.cworth.org Git - turbot/blobdiff - turbot/hunt.py
Use Slack back-tick quoting for search terms
[turbot] / turbot / hunt.py
index a832f1db2693aed5efdc5016d24d2c6f7ccaac93..d6ca6b6909344bb1978ade4ac2079424379fbc8b 100644 (file)
@@ -23,12 +23,6 @@ def find_hunt_for_hunt_id(turb, hunt_id):
     else:
         return None
 
-def quote_if_has_space(term):
-    if ' ' in term:
-        return '"{}"'.format(term)
-    else:
-        return term
-
 def hunt_blocks(turb, hunt, puzzle_status='unsolved', search_terms=[]):
     """Generate Slack blocks for a hunt
 
@@ -46,9 +40,9 @@ def hunt_blocks(turb, hunt, puzzle_status='unsolved', search_terms=[]):
       search_terms: A list of search terms. Only puzzles that match
                     all of these terms will be included in the
                     result. A match will be considered on any of
-                    puzzle title, round title, puzzle URL, or solution
-                    string. Terms can include regular expression
-                    syntax.
+                    puzzle title, round title, puzzle URL, puzzle
+                    state or solution string. Terms can include
+                    regular expression syntax.
 
     The return value can be used in a Slack command expecting blocks to
     provide all the details of a hunt, (puzzles, their state,
@@ -86,15 +80,14 @@ def hunt_blocks(turb, hunt, puzzle_status='unsolved', search_terms=[]):
         for round in puzzle['rounds']:
             rounds.add(round)
 
-    hunt_text = "*{} puzzles in hunt <{}|{}>".format(
+    hunt_text = "*{} puzzles in hunt <{}|{}>*".format(
         puzzle_status.capitalize(),
         channel_url(channel_id),
         name
     )
     if search_terms:
-        quoted_terms = [quote_if_has_space(term) for term in search_terms]
+        quoted_terms = ['`{}`'.format(term) for term in search_terms]
         hunt_text += " matching {}".format(" AND ".join(quoted_terms))
-    hunt_text += "*"
 
     blocks = [
         section_block(text_block(hunt_text)),