From 9f6042ce5001de9880e98f43906f241b67711c97 Mon Sep 17 00:00:00 2001 From: Aevann Date: Fri, 13 Oct 2023 21:56:48 +0300 Subject: [PATCH] make chud award work with owoify award --- files/helpers/owoify.py | 11 ++++++++--- files/helpers/sanitize.py | 4 ++-- files/routes/awards.py | 6 ------ 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/files/helpers/owoify.py b/files/helpers/owoify.py index 3c763c618..d3be0cb54 100644 --- a/files/helpers/owoify.py +++ b/files/helpers/owoify.py @@ -22,7 +22,7 @@ OWO_EXCLUDE_PATTERNS = [ command_regex, # markup commands ] -def owoify(source): +def owoify(source, chud_phrase): if '`' in source or '
' in source or '' in source:
 		return source
 
@@ -32,13 +32,18 @@ def owoify(source):
 	words = [Word(s) for s in word_matches]
 	spaces = [Word(s) for s in space_matches]
 
-	words = list(map(lambda w: owoify_map_token_custom(w), words))
+	chud_words = chud_phrase.split() if chud_phrase else []
+
+	words = list(map(lambda w: owoify_map_token_custom(w, chud_words), words))
 
 	result = interleave_arrays(words, spaces)
 	result_strings = list(map(lambda w: str(w), result))
 	return ''.join(result_strings)
 
-def owoify_map_token_custom(token):
+def owoify_map_token_custom(token, chud_words):
+	if token.word in chud_words:
+		return token
+
 	for pattern in OWO_EXCLUDE_PATTERNS:
 		# if pattern appears anywhere in token, do not owoify.
 		if pattern.search(token.word):
diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py
index 8c2065326..8411d0bd7 100644
--- a/files/helpers/sanitize.py
+++ b/files/helpers/sanitize.py
@@ -378,7 +378,7 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=False, count_emojis
 
 	if obj and not (isinstance(obj, Post) and len(obj.body) > 1000):
 		if author.owoify:
-			sanitized = owoify(sanitized)
+			sanitized = owoify(sanitized, author.chud_phrase)
 		if author.marsify:
 			sanitized = marsify(sanitized, author.chud_phrase)
 
@@ -678,7 +678,7 @@ def filter_emojis_only(title, golden=True, count_emojis=False, obj=None, author=
 
 	if obj and not (isinstance(obj, Post) and len(obj.body) > 1000):
 		if author.owoify:
-			title = owoify(title)
+			title = owoify(title, author.chud_phrase)
 		if author.marsify:
 			title = marsify(title, author.chud_phrase)
 
diff --git a/files/routes/awards.py b/files/routes/awards.py
index a6320f3a6..0496cbf8b 100644
--- a/files/routes/awards.py
+++ b/files/routes/awards.py
@@ -372,9 +372,6 @@ def award_thing(v, thing_type, id):
 		if author.marseyawarded:
 			abort(409, f"{safe_username} under the effect of a conflicting award: Marsey award!")
 
-		if author.owoify:
-			abort(409, f"{safe_username} under the effect of a conflicting award: OwOify award!")
-
 		if author.sharpen:
 			abort(409, f"{safe_username} under the effect of a conflicting award: Sharpen award!")
 
@@ -518,9 +515,6 @@ def award_thing(v, thing_type, id):
 		else: author.earlylife = int(time.time()) + 86400
 		badge_grant(user=author, badge_id=169)
 	elif ("Furry" in kind and kind == v.house) or kind == 'owoify':
-		if author.chud:
-			abort(409, f"{safe_username} under the effect of a conflicting award: Chud award!")
-
 		if author.owoify: author.owoify += 21600
 		else: author.owoify = int(time.time()) + 21600
 		badge_grant(user=author, badge_id=167)