From 58422543a8aeba8e9011403fc49049d3c3730a33 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 11 Jan 2022 19:58:21 -0800 Subject: [PATCH] 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. --- turbot/puzzle.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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': -- 2.43.0