From: Carl Worth Date: Wed, 12 Jan 2022 03:58:21 +0000 (-0800) Subject: Abbreviate round name to only 7 characters in Slack channel name X-Git-Url: https://git.cworth.org/git?p=turbot;a=commitdiff_plain;h=58422543a8aeba8e9011403fc49049d3c3730a33 Abbreviate round name to only 7 characters in Slack channel name 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. --- diff --git a/turbot/puzzle.py b/turbot/puzzle.py index d24a7c9..316620c 100644 --- a/turbot/puzzle.py +++ b/turbot/puzzle.py @@ -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':