From df022bd0039c514f97f1bc53808227f9df7a2363 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 27 Aug 2022 05:22:57 +0200 Subject: [PATCH] make marsify and owoify user-level --- files/classes/user.py | 2 ++ files/helpers/awards.py | 8 +++++++ files/helpers/const.py | 46 +++++++++------------------------------- files/routes/awards.py | 18 +++++++++------- files/routes/comments.py | 12 ++++++++--- 5 files changed, 39 insertions(+), 47 deletions(-) diff --git a/files/classes/user.py b/files/classes/user.py index 69d4139a0..fced5a576 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -133,6 +133,8 @@ class User(Base): pronouns = Column(String, default='they/them') bite = Column(Integer) earlylife = Column(Integer) + owoify = Column(Integer) + marsify = Column(Integer) badges = relationship("Badge", order_by="Badge.created_utc", back_populates="user") subscriptions = relationship("Subscription", back_populates="user") diff --git a/files/helpers/awards.py b/files/helpers/awards.py index 3b1e802b9..a28ddbfa2 100644 --- a/files/helpers/awards.py +++ b/files/helpers/awards.py @@ -82,6 +82,14 @@ def award_timers(v, bot=False): v.earlylife = None notify_if_not_bot("Your earlylife status has expired!") dirty = True + if v.owoify and v.owoify < now: + v.owoify = None + notify_if_not_bot("Your owoify status has expired!") + dirty = True + if v.marsify and v.marsify < now: + v.marsify = None + notify_if_not_bot("Your marsify status has expired!") + dirty = True if dirty: g.db.add(v) diff --git a/files/helpers/const.py b/files/helpers/const.py index d2826ce33..adc8e2ea9 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -775,7 +775,7 @@ HOUSE_AWARDS = { "Furry": { "kind": "Furry", "title": "OwOify", - "description": "OwOifies the comment. Does not work on posts.", + "description": "OwOifies the recipient's comments for 6 hours.", "icon": "fas fa-paw-simple", "color": "text-purple", "price": 400 @@ -783,7 +783,7 @@ HOUSE_AWARDS = { "Femboy": { "kind": "Femboy", "title": "Marsify", - "description": "Emojifies the comment. Does not work on threads.", + "description": "Marsifies the recipient's comments for 6 hours.", "icon": "fas fa-cat", "color": "text-white", "price": 400 @@ -791,10 +791,10 @@ HOUSE_AWARDS = { "Vampire": { "kind": "Vampire", "title": "Bite", - "description": "Turns the recipient into a vampire minion for 24 hours.", + "description": "Turns the recipient into a vampire for 24 hours.", "icon": "fas fa-bat", "color": "text-gray", - "price": 400 + "price": 777 }, "Racist": { "kind": "Racist", @@ -804,40 +804,14 @@ HOUSE_AWARDS = { "color": "text-yellow", "price": 400 }, - "Furry Founder": { - "kind": "Furry Founder", - "title": "OwOify", - "description": "OwOifies the comment. Does not work on posts.", - "icon": "fas fa-paw-simple", - "color": "text-purple", - "price": 300 - }, - "Femboy Founder": { - "kind": "Femboy Founder", - "title": "Marsify", - "description": "Emojifies the comment. Does not work on threads.", - "icon": "fas fa-kiss-wink-heart", - "color": "text-white", - "price": 300 - }, - "Vampire Founder": { - "kind": "Vampire Founder", - "title": "Bite", - "description": "Turns the recipient into a vampire for 24 hours.", - "icon": "fas fa-bat", - "color": "text-gray", - "price": 500 - }, - "Racist Founder": { - "kind": "Racist Founder", - "title": "Early Life", - "description": "Checks the recipient’s Early Life section on Wikipedia. Notices.", - "icon": "fas fa-star-of-david", - "color": "text-yellow", - "price": 300 - }, } +temp = deepcopy(HOUSE_AWARDS).items() +for k, val in temp: + HOUSE_AWARDS[f'{k} Founder'] = val + HOUSE_AWARDS[f'{k} Founder']['kind'] += ' Founder' + HOUSE_AWARDS[f'{k} Founder']['price'] = int(HOUSE_AWARDS[f'{k} Founder']['price'] * 0.75) + if SITE_NAME != 'rDrama': AWARDS_DISABLED.append('progressivestack') diff --git a/files/routes/awards.py b/files/routes/awards.py index 3ebcb081f..ff11c5ad7 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -340,24 +340,26 @@ def award_thing(v, thing_type, id): author.verified = "Verified" badge_grant(user=author, badge_id=150) elif "Vampire" in kind and kind == v.house: - if author.bite: author.bite += 21600 - else: author.bite = int(time.time()) + 21600 + if author.bite: author.bite += 86400 + else: author.bite = int(time.time()) + 86400 author.old_house = author.house author.house = 'Vampire' elif "Racist" in kind and kind == v.house: - if author.earlylife: author.earlylife += 21600 - else: author.earlylife = int(time.time()) + 21600 + if author.earlylife: author.earlylife += 86400 + else: author.earlylife = int(time.time()) + 86400 elif "Furry" in kind and kind == v.house and thing_type == 'comment': + if author.owoify: author.owoify += 21600 + else: author.owoify = int(time.time()) + 21600 body = thing.body body = owoify.owoify(body) - if thing.award_count('Femboy', v) or thing.award_count('Femboy Founder', v): - body = marsify(body) + if author.marsify: body = marsify(body) thing.body_html = sanitize(body, limit_pings=5) g.db.add(thing) elif "Femboy" in kind and kind == v.house and thing_type == 'comment': + if author.marsify: author.marsify += 21600 + else: author.marsify = int(time.time()) + 21600 body = thing.body - if thing.award_count('Furry', v) or thing.award_count('Furry Founder', v): - body = owoify.owoify(body) + if author.owoify: body = owoify.owoify(body) body = marsify(body) thing.body_html = sanitize(body, limit_pings=5) g.db.add(thing) diff --git a/files/routes/comments.py b/files/routes/comments.py index 2d69c6e51..1d97e8f4d 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -291,7 +291,13 @@ def comment(v): if v.agendaposter and not v.marseyawarded and parent_post.id not in ADMIGGERS and parent_post.sub != 'chudrama': body = torture_ap(body, v.username) - body_html = sanitize(body, limit_pings=5) + body_for_sanitize = body + if v.owoify: + body_for_sanitize = owoify.owoify(body_for_sanitize) + if v.marsify: + body_for_sanitize = marsify(body_for_sanitize) + + body_html = sanitize(body_for_sanitize, limit_pings=5) if parent_post.id not in ADMIGGERS and '!slots' not in body.lower() and '!blackjack' not in body.lower() and '!wordle' not in body.lower() and AGENDAPOSTER_PHRASE not in body.lower() and parent_post.sub != 'chudrama': @@ -722,9 +728,9 @@ def edit_comment(cid, v): body = body.strip() body_for_sanitize = body - if c.award_count('Furry', v) or c.award_count('Furry Founder', v): + if v.owoify: body_for_sanitize = owoify.owoify(body_for_sanitize) - if c.award_count('Femboy', v) or c.award_count('Femboy Founder', v): + if v.marsify: body_for_sanitize = marsify(body_for_sanitize) body_html = sanitize(body_for_sanitize, edit=True, limit_pings=5)