From e6c22da6c542118fdf7d0b57470bf264715d9603 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 5 May 2022 16:47:34 -0400 Subject: [PATCH] test --- spicebot_command_leetspeak/__init__.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/spicebot_command_leetspeak/__init__.py b/spicebot_command_leetspeak/__init__.py index b07a395..9990f66 100644 --- a/spicebot_command_leetspeak/__init__.py +++ b/spicebot_command_leetspeak/__init__.py @@ -46,19 +46,21 @@ def leet_convert(message): "y": ["j", "`/", "\\|/", "\\//"], "z": ["2", "7_", "-/_", "%", ">_", "~/_", "-\_", "-|_"], } - leetspeak = "" + leetspeak = [] for word in message.split(" "): if word.lower() in [old for old, new in replacements]: leet_word = word.replace([old for old, new in replacements][0], [new for old, new in replacements][0]) - leetspeak = leetspeak + leet_word + leetspeak.append(leet_word) else: + word_chars = [] for char in word: if char.lower() in char_map and random.random() <= 0.70: # 70% convert possible_replacements = char_map[char.lower()] leet_replacement = random.choice(possible_replacements) - leetspeak = leetspeak + leet_replacement + word_chars.append(leet_replacement) else: - leetspeak = leetspeak + char + word_chars.append(char) + leetspeak.append("".join(word_chars)) - return leetspeak + return " ".join(leetspeak)