awards: remove all award definitions

This commit is contained in:
justcool393 2023-01-20 01:54:09 -06:00 committed by Ben Rog-Wilhelm
parent 9211f17e25
commit 86ea70dfd3
3 changed files with 19 additions and 254 deletions

View file

@ -224,13 +224,9 @@ class User(Base):
@property
@lazy
def user_awards(self):
return_value = list(AWARDS2.values())
return_value = list(AWARDS_ENABLED.values())
user_awards = g.db.query(AwardRelationship).filter_by(user_id=self.id)
for val in return_value: val['owned'] = user_awards.filter_by(kind=val['kind'], submission_id=None, comment_id=None).count()
return return_value
@property

View file

@ -79,121 +79,16 @@ PERMS = {
"DEBUG_LOGIN_TO_OTHERS": 3,
}
AWARDS = {
"lootbox": {
"kind": "lootbox",
"title": "Lootstocking",
"description": "???",
"icon": "fas fa-stocking",
"color": "text-danger",
"price": 1000
},
"shit": {
"kind": "shit",
"title": "Shit",
"description": "Makes flies swarm the post.",
"icon": "fas fa-poop",
"color": "text-black-50",
"price": 300
},
"fireflies": {
"kind": "fireflies",
"title": "Fireflies",
"description": "Makes fireflies swarm the post.",
"icon": "fas fa-sparkles",
"color": "text-warning",
"price": 300
},
"train": {
"kind": "train",
"title": "Train",
"description": "Summons a train on the post.",
"icon": "fas fa-train",
"color": "text-pink",
"price": 300
},
"scooter": {
"kind": "scooter",
"title": "Scooter",
"description": "Summons a scooter on the post.",
"icon": "fas fa-flag-usa",
"color": "text-muted",
"price": 300
},
"wholesome": {
"kind": "wholesome",
"title": "Wholesome",
"description": "Summons a wholesome marsey on the post.",
"icon": "fas fa-smile-beam",
"color": "text-yellow",
"price": 300
},
"glowie": {
"kind": "glowie",
"title": "Glowie",
"description": "Indicates that the recipient can be seen when driving. Just run them over.",
"icon": "fas fa-user-secret",
"color": "text-green",
"price": 300
},
"pin": {
"kind": "pin",
"title": "1-Hour Pin",
"description": "Pins the post/comment.",
"icon": "fas fa-thumbtack fa-rotate--45",
"color": "text-warning",
"price": 1000
},
"unpin": {
"kind": "unpin",
"title": "1-Hour Unpin",
"description": "Removes 1 hour from the pin duration of the post/comment.",
"icon": "fas fa-thumbtack fa-rotate--45",
"color": "text-black",
"price": 1000
},
"ban": {
"kind": "ban",
"title": "1-Day Ban",
"description": "Bans the recipient for a day.",
"icon": "fas fa-gavel",
"color": "text-danger",
"price": 3000
},
"unban": {
"kind": "unban",
"title": "1-Day Unban",
"description": "Removes 1 day from the ban duration of the recipient.",
"icon": "fas fa-gavel",
"color": "text-success",
"price": 3500
},
"benefactor": {
"kind": "benefactor",
"title": "Benefactor",
"description": "Grants one month of paypig status and 2500 marseybux to the recipient. Cannot be used on yourself.",
"icon": "fas fa-gift",
"color": "text-blue",
"price": 4000
},
"grass": {
"kind": "grass",
"title": "Grass",
"description": "Doesn't do anything",
"icon": "fas fa-seedling",
"color": "text-success",
"price": 10000
},
}
AWARDS = {}
AWARDS2 = deepcopy(AWARDS)
AWARDS_ENABLED = deepcopy(AWARDS)
for k, val in AWARDS.items():
if val['description'] == '???': AWARDS2.pop(k)
if val['description'] == '???': AWARDS_ENABLED.pop(k)
AWARDS3 = {}
for k, val in AWARDS2.items():
if val['price'] == 300: AWARDS3[k] = val
AWARDS_JL2_PRINTABLE = {}
for k, val in AWARDS_ENABLED.items():
if val['price'] == 300: AWARDS_JL2_PRINTABLE[k] = val
NOTIFIED_USERS = {
# format: 'substring' ↦ User ID to notify

View file

@ -15,7 +15,7 @@ from copy import deepcopy
def shop(v):
abort(404) # disable entirely pending possible future use of coins
AWARDS = deepcopy(AWARDS2)
AWARDS = deepcopy(AWARDS_ENABLED)
for val in AWARDS.values(): val["owned"] = 0
@ -41,7 +41,7 @@ def buy(v, award):
if award == 'ghost' and v.admin_level < 2:
abort(403, "Only admins can buy that award.")
AWARDS = deepcopy(AWARDS2)
AWARDS = deepcopy(AWARDS_ENABLED)
if award not in AWARDS: abort(400)
og_price = AWARDS[award]["price"]
@ -50,7 +50,6 @@ def buy(v, award):
if request.values.get("mb"):
if v.procoins < price: abort(400, "Not enough marseybux.")
if award == "grass": abort(403, "You can't buy the grass award with marseybux.")
v.procoins -= price
else:
if v.coins < price: abort(400, "Not enough coins.")
@ -85,31 +84,6 @@ def buy(v, award):
g.db.add(v)
if award == "lootbox":
send_repeatable_notification(995, f"@{v.username} bought a lootbox!")
for i in [1,2,3,4,5]:
award = random.choice(["snow", "gingerbread", "lights", "candycane", "fireplace"])
award = AwardRelationship(user_id=v.id, kind=award)
g.db.add(award)
g.db.flush()
v.lootboxes_bought += 1
if v.lootboxes_bought == 10 and not v.has_badge(76):
new_badge = Badge(badge_id=76, user_id=v.id)
g.db.add(new_badge)
g.db.flush()
send_notification(v.id, f"@AutoJanny has given you the following profile badge:\n\n![]({new_badge.path})\n\n{new_badge.name}")
elif v.lootboxes_bought == 50 and not v.has_badge(77):
new_badge = Badge(badge_id=77, user_id=v.id)
g.db.add(new_badge)
g.db.flush()
send_notification(v.id, f"@AutoJanny has given you the following profile badge:\n\n![]({new_badge.path})\n\n{new_badge.name}")
elif v.lootboxes_bought == 150 and not v.has_badge(78):
new_badge = Badge(badge_id=78, user_id=v.id)
g.db.add(new_badge)
g.db.flush()
send_notification(v.id, f"@AutoJanny has given you the following profile badge:\n\n![]({new_badge.path})\n\n{new_badge.name}")
else:
award_object = AwardRelationship(user_id=v.id, kind=award)
g.db.add(award_object)
@ -161,54 +135,6 @@ def award_post(pid, v):
if note: msg += f"\n\n> {note}"
send_repeatable_notification(author.id, msg)
if kind == "ban":
link = f"[this post]({post.shortlink})"
if not author.is_suspended:
author.ban(reason=f"1-Day ban award used by @{v.username} on /post/{post.id}", days=1)
send_repeatable_notification(author.id, f"Your account has been banned for **a day** for {link}. It sucked and you should feel bad.")
elif author.unban_utc:
author.unban_utc += 86400
send_repeatable_notification(author.id, f"Your account has been banned for **yet another day** for {link}. Seriously man?")
elif kind == "unban":
if not author.is_suspended or not author.unban_utc or time.time() > author.unban_utc: abort(403)
if author.unban_utc - time.time() > 86400:
author.unban_utc -= 86400
send_repeatable_notification(author.id, "Your ban duration has been reduced by 1 day!")
else:
author.unban_utc = 0
author.is_banned = 0
author.ban_evade = 0
send_repeatable_notification(author.id, "You have been unbanned!")
elif kind == "pin":
if post.stickied and post.stickied_utc:
post.stickied_utc += 3600
else:
post.stickied = f'{v.username} (pin award)'
post.stickied_utc = int(time.time()) + 3600
g.db.add(post)
cache.delete_memoized(frontlist)
elif kind == "unpin":
if not post.stickied_utc: abort(403)
t = post.stickied_utc - 3600
if time.time() > t:
post.stickied = None
post.stickied_utc = None
cache.delete_memoized(frontlist)
else: post.stickied_utc = t
g.db.add(post)
elif kind == "benefactor":
author.patron = 1
if author.patron_utc: author.patron_utc += 2629746
else: author.patron_utc = int(time.time()) + 2629746
author.procoins += 2500
if not v.has_badge(103):
badge = Badge(user_id=v.id, badge_id=103)
g.db.add(badge)
g.db.flush()
send_notification(v.id, f"@AutoJanny has given you the following profile badge:\n\n![]({badge.path})\n\n{badge.name}")
if author.received_award_count: author.received_award_count += 1
else: author.received_award_count = 1
g.db.add(author)
@ -260,54 +186,6 @@ def award_comment(cid, v):
if note: msg += f"\n\n> {note}"
send_repeatable_notification(author.id, msg)
if kind == "benefactor" and author.id == v.id:
abort(400, "You can't use this award on yourself.")
if kind == "ban":
link = f"[this comment]({c.shortlink})"
if not author.is_suspended:
author.ban(reason=f"1-Day ban award used by @{v.username} on /comment/{c.id}", days=1)
send_repeatable_notification(author.id, f"Your account has been banned for **a day** for {link}. It sucked and you should feel bad.")
elif author.unban_utc:
author.unban_utc += 86400
send_repeatable_notification(author.id, f"Your account has been banned for **yet another day** for {link}. Seriously man?")
elif kind == "unban":
if not author.is_suspended or not author.unban_utc or time.time() > author.unban_utc: abort(403)
if author.unban_utc - time.time() > 86400:
author.unban_utc -= 86400
send_repeatable_notification(author.id, "Your ban duration has been reduced by 1 day!")
else:
author.unban_utc = 0
author.is_banned = 0
author.ban_evade = 0
send_repeatable_notification(author.id, "You have been unbanned!")
elif kind == "pin":
if c.is_pinned and c.is_pinned_utc: c.is_pinned_utc += 3600
else:
c.is_pinned = f'{v.username} (pin award)'
c.is_pinned_utc = int(time.time()) + 3600
g.db.add(c)
elif kind == "unpin":
if not c.is_pinned_utc: abort(403)
t = c.is_pinned_utc - 3600
if time.time() > t:
c.is_pinned = None
c.is_pinned_utc = None
else: c.is_pinned_utc = t
g.db.add(c)
elif kind == "benefactor":
author.patron = 1
if author.patron_utc: author.patron_utc += 2629746
else: author.patron_utc = int(time.time()) + 2629746
author.procoins += 2500
if not v.has_badge(103):
badge = Badge(user_id=v.id, badge_id=103)
g.db.add(badge)
g.db.flush()
send_notification(v.id, f"@AutoJanny has given you the following profile badge:\n\n![]({badge.path})\n\n{badge.name}")
if author.received_award_count: author.received_award_count += 1
else: author.received_award_count = 1
g.db.add(author)
@ -323,7 +201,7 @@ def admin_userawards_get(v):
abort(404) # disable entirely pending possible future use of coins
if v.admin_level != 3:
return render_template("admin/awards.html", awards=list(AWARDS3.values()), v=v)
return render_template("admin/awards.html", awards=list(AWARDS_JL2_PRINTABLE.values()), v=v)
return render_template("admin/awards.html", awards=list(AWARDS.values()), v=v)
@ -335,22 +213,15 @@ def admin_userawards_post(v):
try: u = request.values.get("username").strip()
except: abort(404)
whitelist = ("shit", "fireflies", "train", "scooter", "wholesome", "glowie")
whitelist = ()
u = get_user(u, graceful=False, v=v)
notify_awards = {}
for key, value in request.values.items():
if key not in AWARDS: continue
if v.admin_level < 3 and key not in whitelist: continue
if value:
if int(value) > 10: abort(403)
if int(value): notify_awards[key] = int(value)
for x in range(int(value)):
@ -358,7 +229,6 @@ def admin_userawards_post(v):
user_id=u.id,
kind=key
)
g.db.add(award)
if v.id != u.id:
@ -384,5 +254,9 @@ def admin_userawards_post(v):
g.db.commit()
if v.admin_level != 3: return render_template("admin/awards.html", awards=list(AWARDS3.values()), v=v)
return render_template("admin/awards.html", awards=list(AWARDS.values()), v=v)
if v.admin_level < 3:
awards: dict = AWARDS_JL2_PRINTABLE
else:
awards: dict = AWARDS
return render_template("admin/awards.html", awards=awards, v=v)