diff --git a/files/helpers/const.py b/files/helpers/const.py index 61bc3fdfa..b6617b3cd 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -463,6 +463,10 @@ BADGES = { 'name': 'Christmas 21', 'description': 'Awarded for surviving Fistmas 2021' }, + 103: { + 'name': 'Benefactor', + 'description': 'Gave the Benefactor award to someone' + }, } AWARDS = { @@ -682,6 +686,14 @@ AWARDS = { "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-purple", + "price": 4000 + }, "grass": { "kind": "grass", "title": "Grass", diff --git a/files/routes/awards.py b/files/routes/awards.py index f99c9a341..95c545ced 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -215,6 +215,10 @@ def award_post(pid, v): send_repeatable_notification(post.author.id, msg) author = post.author + + if kind == "benefactor" and author.id == v.id: + return {"error": "You can't use this award on yourself."}, 400 + if kind == "ban": link = f"[this post]({post.permalink})" @@ -350,6 +354,13 @@ def award_post(pid, v): 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}") + elif kind == "benefactor": + author.patron = 1 + author.procoins += 2500 + if not v.has_badge(103): + badge = Badge(user_id=v.id, badge_id=103) + g.db.add(badge) + send_notification(v.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 @@ -403,6 +414,9 @@ def award_comment(cid, v): author = c.author + if kind == "benefactor" and author.id == v.id: + return {"error": "You can't use this award on yourself."}, 400 + if kind == "ban": link = f"[this comment]({c.permalink})" @@ -535,6 +549,13 @@ def award_comment(cid, v): 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}") + elif kind == "benefactor": + author.patron = 1 + author.procoins += 2500 + if not v.has_badge(103): + badge = Badge(user_id=v.id, badge_id=103) + g.db.add(badge) + send_notification(v.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