forked from MarseyWorld/MarseyWorld
make chud award work with marsify award
parent
93c282b148
commit
4a6cd663cd
|
@ -1,6 +1,12 @@
|
|||
from random import choice
|
||||
|
||||
from .const_stateful import MARSEY_MAPPINGS
|
||||
from .config.const import *
|
||||
|
||||
chud_words = set()
|
||||
|
||||
for phrase in CHUD_PHRASES:
|
||||
chud_words.update(phrase.lower().split())
|
||||
|
||||
def marsify(text):
|
||||
if '`' in text or '<pre>' in text or '<code>' in text:
|
||||
|
@ -10,6 +16,7 @@ def marsify(text):
|
|||
for x in text.split(' '):
|
||||
new_text += f'{x} '
|
||||
x = x.lower()
|
||||
if x in chud_words: continue
|
||||
if len(x) >= 5 and x in MARSEY_MAPPINGS:
|
||||
marsey = choice(MARSEY_MAPPINGS[x])
|
||||
new_text += f':{marsey}: '
|
||||
|
|
|
@ -379,7 +379,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)
|
||||
if author.marsify and not author.chud:
|
||||
if author.marsify:
|
||||
sanitized = marsify(sanitized)
|
||||
|
||||
if obj and obj.sharpened:
|
||||
|
@ -679,7 +679,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)
|
||||
if author.marsify and not author.chud:
|
||||
if author.marsify:
|
||||
title = marsify(title)
|
||||
|
||||
if obj and obj.sharpened:
|
||||
|
|
|
@ -493,8 +493,6 @@ def award_thing(v, thing_type, id):
|
|||
elif kind == "pride":
|
||||
badge_grant(user=author, badge_id=303)
|
||||
elif kind == 'marsify':
|
||||
if author.chud:
|
||||
abort(409, f"{safe_username} under the effect of a conflicting award: Chud award!")
|
||||
if not author.marsify or author.marsify != 1:
|
||||
if author.marsify: author.marsify += 86400
|
||||
else: author.marsify = int(time.time()) + 86400
|
||||
|
|
Loading…
Reference in New Issue