forked from rDrama/rDrama
make chud award work with owoify award
parent
fcac9b50be
commit
9f6042ce50
|
@ -22,7 +22,7 @@ OWO_EXCLUDE_PATTERNS = [
|
||||||
command_regex, # markup commands
|
command_regex, # markup commands
|
||||||
]
|
]
|
||||||
|
|
||||||
def owoify(source):
|
def owoify(source, chud_phrase):
|
||||||
if '`' in source or '<pre>' in source or '<code>' in source:
|
if '`' in source or '<pre>' in source or '<code>' in source:
|
||||||
return source
|
return source
|
||||||
|
|
||||||
|
@ -32,13 +32,18 @@ def owoify(source):
|
||||||
words = [Word(s) for s in word_matches]
|
words = [Word(s) for s in word_matches]
|
||||||
spaces = [Word(s) for s in space_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 = interleave_arrays(words, spaces)
|
||||||
result_strings = list(map(lambda w: str(w), result))
|
result_strings = list(map(lambda w: str(w), result))
|
||||||
return ''.join(result_strings)
|
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:
|
for pattern in OWO_EXCLUDE_PATTERNS:
|
||||||
# if pattern appears anywhere in token, do not owoify.
|
# if pattern appears anywhere in token, do not owoify.
|
||||||
if pattern.search(token.word):
|
if pattern.search(token.word):
|
||||||
|
|
|
@ -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 obj and not (isinstance(obj, Post) and len(obj.body) > 1000):
|
||||||
if author.owoify:
|
if author.owoify:
|
||||||
sanitized = owoify(sanitized)
|
sanitized = owoify(sanitized, author.chud_phrase)
|
||||||
if author.marsify:
|
if author.marsify:
|
||||||
sanitized = marsify(sanitized, author.chud_phrase)
|
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 obj and not (isinstance(obj, Post) and len(obj.body) > 1000):
|
||||||
if author.owoify:
|
if author.owoify:
|
||||||
title = owoify(title)
|
title = owoify(title, author.chud_phrase)
|
||||||
if author.marsify:
|
if author.marsify:
|
||||||
title = marsify(title, author.chud_phrase)
|
title = marsify(title, author.chud_phrase)
|
||||||
|
|
||||||
|
|
|
@ -372,9 +372,6 @@ def award_thing(v, thing_type, id):
|
||||||
if author.marseyawarded:
|
if author.marseyawarded:
|
||||||
abort(409, f"{safe_username} under the effect of a conflicting award: Marsey award!")
|
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:
|
if author.sharpen:
|
||||||
abort(409, f"{safe_username} under the effect of a conflicting award: Sharpen award!")
|
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
|
else: author.earlylife = int(time.time()) + 86400
|
||||||
badge_grant(user=author, badge_id=169)
|
badge_grant(user=author, badge_id=169)
|
||||||
elif ("Furry" in kind and kind == v.house) or kind == 'owoify':
|
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
|
if author.owoify: author.owoify += 21600
|
||||||
else: author.owoify = int(time.time()) + 21600
|
else: author.owoify = int(time.time()) + 21600
|
||||||
badge_grant(user=author, badge_id=167)
|
badge_grant(user=author, badge_id=167)
|
||||||
|
|
Loading…
Reference in New Issue