From b0d56b91efaa9a58c30f69468672d82cd607ff14 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 7 Jan 2022 00:28:27 +0200 Subject: [PATCH] fds --- files/helpers/const.py | 2 +- files/routes/awards.py | 40 ++++++++++++++++++++++++++++++++++++++++ files/routes/front.py | 10 ++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/files/helpers/const.py b/files/helpers/const.py index f39370229..b1db36666 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -295,7 +295,7 @@ BADGES = { 'description': 'Contributed at least $100' }, 26: { - 'name': 'Agendaposter', + 'name': 'Rightoid Agendaposter', 'description': 'Forced to use the agendaposter theme' }, 27: { diff --git a/files/routes/awards.py b/files/routes/awards.py index 666b2144c..05e336b6f 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -277,6 +277,10 @@ def award_post(pid, v): author.customtitle = filter_emojis_only(new_name) if len(author.customtitle) > 1000: abort(403) author.flairchanged = int(time.time()) + 86400 + if not author.has_badge(96): + badge = Badge(user_id=author.id, badge_id=96) + g.db.add(badge) + send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({badge.path})\n\n{badge.name}") elif kind == "pause": author.mute = True if not author.has_badge(68): @@ -292,16 +296,28 @@ def award_post(pid, v): elif kind == "marsey": if author.marseyawarded: author.marseyawarded += 86400 else: author.marseyawarded = int(time.time()) + 86400 + if not author.has_badge(98): + badge = Badge(user_id=author.id, badge_id=98) + g.db.add(badge) + send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({badge.path})\n\n{badge.name}") elif kind == "pizzashill": if author.bird: return {"error": "This user is the under the effect of a conflicting award: Bird Site award."}, 404 if author.longpost: author.longpost += 86400 else: author.longpost = int(time.time()) + 86400 + if not author.has_badge(97): + badge = Badge(user_id=author.id, badge_id=97) + g.db.add(badge) + send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({badge.path})\n\n{badge.name}") elif kind == "bird": if author.longpost: return {"error": "This user is the under the effect of a conflicting award: Pizzashill award."}, 404 if author.bird: author.bird += 86400 else: author.bird = int(time.time()) + 86400 + if not author.has_badge(95): + badge = Badge(user_id=author.id, badge_id=95) + g.db.add(badge) + send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({badge.path})\n\n{badge.name}") elif kind == "eye": author.eye = True if not author.has_badge(83): @@ -330,6 +346,10 @@ def award_post(pid, v): elif kind == "progressivestack": if author.progressivestack: author.progressivestack += 21600 else: author.progressivestack = int(time.time()) + 21600 + if not author.has_badge(94): + badge = Badge(user_id=author.id, badge_id=94) + g.db.add(badge) + send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({badge.path})\n\n{badge.name}") if post.author.received_award_count: post.author.received_award_count += 1 else: post.author.received_award_count = 1 @@ -438,6 +458,10 @@ def award_comment(cid, v): author.customtitle = filter_emojis_only(new_name) if len(author.customtitle) > 1000: abort(403) author.flairchanged = int(time.time()) + 86400 + if not author.has_badge(96): + badge = Badge(user_id=author.id, badge_id=96) + g.db.add(badge) + send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({badge.path})\n\n{badge.name}") elif kind == "pause": author.mute = True if not author.has_badge(68): @@ -453,16 +477,28 @@ def award_comment(cid, v): elif kind == "marsey": if author.marseyawarded: author.marseyawarded += 86400 else: author.marseyawarded = int(time.time()) + 86400 + if not author.has_badge(98): + badge = Badge(user_id=author.id, badge_id=98) + g.db.add(badge) + send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({badge.path})\n\n{badge.name}") elif kind == "pizzashill": if author.bird: return {"error": "This user is the under the effect of a conflicting award: Bird Site award."}, 404 if author.longpost: author.longpost += 86400 else: author.longpost = int(time.time()) + 86400 + if not author.has_badge(97): + badge = Badge(user_id=author.id, badge_id=97) + g.db.add(badge) + send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({badge.path})\n\n{badge.name}") elif kind == "bird": if author.longpost: return {"error": "This user is the under the effect of a conflicting award: Pizzashill award."}, 404 if author.bird: author.bird += 86400 else: author.bird = int(time.time()) + 86400 + if not author.has_badge(95): + badge = Badge(user_id=author.id, badge_id=95) + g.db.add(badge) + send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({badge.path})\n\n{badge.name}") elif kind == "eye": author.eye = True if not author.has_badge(83): @@ -491,6 +527,10 @@ def award_comment(cid, v): elif kind == "progressivestack": if author.progressivestack: author.progressivestack += 21600 else: author.progressivestack = int(time.time()) + 21600 + if not author.has_badge(94): + badge = Badge(user_id=author.id, badge_id=94) + g.db.add(badge) + send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({badge.path})\n\n{badge.name}") if c.author.received_award_count: c.author.received_award_count += 1 else: c.author.received_award_count = 1 diff --git a/files/routes/front.py b/files/routes/front.py index 01231fbb0..eeb350eab 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -171,30 +171,40 @@ def front_all(v): v.flairchanged = None send_repeatable_notification(v.id, "Your flair lock has expired. You can now change your flair!") g.db.add(v) + badge = v.has_badge(96) + if badge: g.db.delete(badge) g.db.commit() if v.marseyawarded and v.marseyawarded < time.time(): v.marseyawarded = None send_repeatable_notification(v.id, "Your marsey award has expired!") g.db.add(v) + badge = v.has_badge(98) + if badge: g.db.delete(badge) g.db.commit() if v.longpost and v.longpost < time.time(): v.longpost = None send_repeatable_notification(v.id, "Your pizzashill award has expired!") g.db.add(v) + badge = v.has_badge(97) + if badge: g.db.delete(badge) g.db.commit() if v.bird and v.bird < time.time(): v.bird = None send_repeatable_notification(v.id, "Your bird site award has expired!") g.db.add(v) + badge = v.has_badge(95) + if badge: g.db.delete(badge) g.db.commit() if v.progressivestack and v.progressivestack < time.time(): v.progressivestack = None send_repeatable_notification(v.id, "Your progressive stack has expired!") g.db.add(v) + badge = v.has_badge(94) + if badge: g.db.delete(badge) g.db.commit() if request.headers.get("Authorization"): return {"data": [x.json for x in posts], "next_exists": next_exists}