]> git.cworth.org Git - turbot/commitdiff
Abbreviate round name to only 7 characters in Slack channel name
authorCarl Worth <cworth@cworth.org>
Wed, 12 Jan 2022 03:58:21 +0000 (19:58 -0800)
committerCarl Worth <cworth@cworth.org>
Wed, 12 Jan 2022 04:05:16 +0000 (20:05 -0800)
Some users were nervous about the round portion of the channel name
overwhelming the space available for channel names, making it
impossible to distinguish one puzzle channel from another in the same
round. Restricting the round prefix to only 7 letters should help
mitigate that.

turbot/puzzle.py

index d24a7c9a4da955120f565a3ea43db4e8d66f61d5..316620c085da5d8936d808f06ec0e747a8c88c26 100644 (file)
@@ -223,6 +223,12 @@ def puzzle_matches_all(puzzle, patterns):
 def puzzle_id_from_name(name):
     return re.sub(r'[^a-zA-Z0-9_]', '', name).lower()
 
+def round_id_from_name(name):
+    """Normalize and abbreviate round name for use as a prefix
+       in a channel name."""
+
+    return re.sub(r'[^a-zA-Z0-9_]', '', name).lower()[:7]
+
 def puzzle_sort_key(puzzle):
     """Return an appropriate sort key for a puzzle in the database
 
@@ -308,7 +314,7 @@ def puzzle_channel_name(puzzle):
 
     round = ''
     if 'rounds' in puzzle:
-        round = '-' + puzzle_id_from_name(puzzle['rounds'][0])
+        round = '-' + round_id_from_name(puzzle['rounds'][0])
 
     meta = ''
     if puzzle.get('type', 'plain') == 'meta':