From 9739a1691c459e49c0c583d9f739a518f7ee5787 Mon Sep 17 00:00:00 2001 From: josiah Date: Sat, 25 Jan 2020 03:31:55 +0000 Subject: [PATCH 1/6] 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: From 6ec3083b3aaca27fb4fde9efb79cddae61c9bf8b Mon Sep 17 00:00:00 2001 From: josiah Date: Sat, 25 Jan 2020 03:42:53 +0000 Subject: [PATCH 2/6] Stop using async --- mojo-rtm/mojo-rtm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mojo-rtm/mojo-rtm.py b/mojo-rtm/mojo-rtm.py index f04469b..7f0dd7a 100644 --- a/mojo-rtm/mojo-rtm.py +++ b/mojo-rtm/mojo-rtm.py @@ -19,7 +19,7 @@ def parse_direct_mention(message_text): return (matches.group(1), matches.group(2).strip()) if matches else (None, None) -async def zalgo_ify(text): +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)] From 4438d66ed1b32079331c38b0dd95c9b2ed6847bc Mon Sep 17 00:00:00 2001 From: josiah Date: Sat, 25 Jan 2020 03:54:31 +0000 Subject: [PATCH 3/6] Add var definition - goddamnit i'm a fucking moron. --- mojo-rtm/mojo-rtm.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mojo-rtm/mojo-rtm.py b/mojo-rtm/mojo-rtm.py index 7f0dd7a..368963f 100644 --- a/mojo-rtm/mojo-rtm.py +++ b/mojo-rtm/mojo-rtm.py @@ -95,7 +95,8 @@ def handle_messages(**payload): for line in json_File: response.append(json.loads(line)) elif "zalgo" in is_command[1]: - zalgo_ify(is_command[1]) + response = zalgo_ify(is_command[1]) + elif "pence" in is_command[1]: response = "mother wouldn't want me to say that" else: From fea8bcc7bdddacba29f6dc69e1f7caec6b2ced82 Mon Sep 17 00:00:00 2001 From: josiah Date: Sat, 25 Jan 2020 03:59:27 +0000 Subject: [PATCH 4/6] Add random import. --- mojo-rtm/mojo-rtm.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mojo-rtm/mojo-rtm.py b/mojo-rtm/mojo-rtm.py index 368963f..c0ee6dd 100644 --- a/mojo-rtm/mojo-rtm.py +++ b/mojo-rtm/mojo-rtm.py @@ -2,6 +2,7 @@ import os import re import json import slack +import random EXAMPLE_COMMAND = "do" MENTION_REGEX = "^<@(|[WU].+)>(.*)" From a0ee9f1702a11b8272b0149d9e4126e949c474a8 Mon Sep 17 00:00:00 2001 From: josiah Date: Sat, 25 Jan 2020 04:46:27 +0000 Subject: [PATCH 5/6] Update zalgo logic to remove 'zalgo' from response - now it should be prettier! --- mojo-rtm/mojo-rtm.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mojo-rtm/mojo-rtm.py b/mojo-rtm/mojo-rtm.py index c0ee6dd..d911612 100644 --- a/mojo-rtm/mojo-rtm.py +++ b/mojo-rtm/mojo-rtm.py @@ -96,8 +96,9 @@ def handle_messages(**payload): for line in json_File: response.append(json.loads(line)) elif "zalgo" in is_command[1]: - response = zalgo_ify(is_command[1]) - + # remove zalgo + name_removal = re.sub("^zalgo .*?", "", "is_command[1]") + response = zalgo_ify(name_removal) elif "pence" in is_command[1]: response = "mother wouldn't want me to say that" else: From 3920131cb6a18af73141876b1a4332f3bf65655b Mon Sep 17 00:00:00 2001 From: josiah Date: Sat, 25 Jan 2020 04:52:40 +0000 Subject: [PATCH 6/6] Remove the quotes that have betrayed me --- mojo-rtm/mojo-rtm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mojo-rtm/mojo-rtm.py b/mojo-rtm/mojo-rtm.py index d911612..a373dd8 100644 --- a/mojo-rtm/mojo-rtm.py +++ b/mojo-rtm/mojo-rtm.py @@ -97,7 +97,7 @@ def handle_messages(**payload): response.append(json.loads(line)) elif "zalgo" in is_command[1]: # remove zalgo - name_removal = re.sub("^zalgo .*?", "", "is_command[1]") + name_removal = re.sub("^zalgo .*?", "", is_command[1]) response = zalgo_ify(name_removal) elif "pence" in is_command[1]: response = "mother wouldn't want me to say that"