make chud award work with owoify award

pull/216/head
Aevann 2023-10-13 21:56:48 +03:00
parent fcac9b50be
commit 9f6042ce50
3 changed files with 10 additions and 11 deletions

View File

@ -22,7 +22,7 @@ OWO_EXCLUDE_PATTERNS = [
command_regex, # markup commands
]
def owoify(source):
def owoify(source, chud_phrase):
if '`' in source or '<pre>' in source or '<code>' 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):

View File

@ -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)

View File

@ -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)