This commit is contained in:
deathbybandaid 2022-05-05 16:44:42 -04:00
parent bacf4f22a5
commit e3f6c6e369

View File

@ -15,6 +15,9 @@ def leatspeak(bot, trigger, comrun):
def leet_convert(message):
message = message.strip()
replacements = (('hacker', 'haxor'), ('elite', 'eleet'), ('a', '4'), ('e', '3'),
('l', '1'), ('o', '0'), ('t', '+'))
char_map = {
"a": ["4", "@", "/-\\", "^"],
"b": ["I3", "8", "13", "|3"],
@ -44,11 +47,18 @@ def leet_convert(message):
"z": ["2", "7_", "-/_", "%", ">_", "~/_", "-\_", "-|_"],
}
leetspeak = ""
for char in message:
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
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
else:
leetspeak = leetspeak + char
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
else:
leetspeak = leetspeak + char
return leetspeak