From 9739a1691c459e49c0c583d9f739a518f7ee5787 Mon Sep 17 00:00:00 2001 From: josiah Date: Sat, 25 Jan 2020 03:31:55 +0000 Subject: [PATCH] Add initial zalgo function. --- mojo-rtm/mojo-rtm.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/mojo-rtm/mojo-rtm.py b/mojo-rtm/mojo-rtm.py index 2b3da53..f04469b 100644 --- a/mojo-rtm/mojo-rtm.py +++ b/mojo-rtm/mojo-rtm.py @@ -19,6 +19,19 @@ def parse_direct_mention(message_text): return (matches.group(1), matches.group(2).strip()) if matches else (None, None) +async def zalgo_ify(text): + ''' Takes some normal text and zalgo-ifies it ''' + # "Combining Diacritical Marks" Unicode block. + combining_chars = [chr(n) for n in range(768, 878)] + + zalgo_text = '' + + for char in text: + combining_char = random.choice(combining_chars) + zalgo_text += f'{char}{combining_char}' + + return zalgo_text + def reactable_string(text): """ Return regex objects matching interesting strings @@ -81,6 +94,8 @@ def handle_messages(**payload): with open("/shared/state.log", "r") as json_File: for line in json_File: response.append(json.loads(line)) + elif "zalgo" in is_command[1]: + zalgo_ify(is_command[1]) elif "pence" in is_command[1]: response = "mother wouldn't want me to say that" else: