diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..25c729f58 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.pythonPath": "/bin/python3" +} \ No newline at end of file diff --git a/files/classes/user.py b/files/classes/user.py index 80552d217..528369ad5 100755 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -89,6 +89,7 @@ class User(Base): reserved = Column(String) coins = Column(Integer, default=0) truecoins = Column(Integer, default=0) + procoins = Column(Integer, default=0) mfa_secret = deferred(Column(String)) is_private = Column(Boolean, default=False) stored_subscriber_count = Column(Integer, default=0) diff --git a/files/routes/admin.py b/files/routes/admin.py index 706afce3b..c8e67fec2 100755 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -172,62 +172,18 @@ def monthly(v): if 'pcm' in request.host or (SITE_NAME == 'Drama' and v.id in [1,12,28,29,747,995,1480]) or ('rama' not in request.host and 'pcm' not in request.host): thing = g.db.query(AwardRelationship).order_by(AwardRelationship.id.desc()).first().id for u in g.db.query(User).options(lazyload('*')).filter(User.patron > 0).all(): - grant_awards = {} + if u.patron == 1: procoins = 2000 + elif u.patron == 2: procoins = 5000 + elif u.patron == 3: procoins = 10000 + elif u.patron == 4: procoins = 25000 + elif u.patron == 5 or u.patron == 8: procoins = 50000 - if u.patron == 1: - grant_awards["shit"] = 1 - grant_awards["fireflies"] = 1 - grant_awards["train"] = 1 - elif u.patron == 2: - grant_awards["shit"] = 2 - grant_awards["fireflies"] = 2 - grant_awards["train"] = 2 - grant_awards["ban"] = 1 - elif u.patron == 3: - grant_awards["shit"] = 5 - grant_awards["fireflies"] = 5 - grant_awards["train"] = 5 - grant_awards["ban"] = 2 - elif u.patron == 4: - grant_awards["shit"] = 10 - grant_awards["fireflies"] = 10 - grant_awards["train"] = 10 - grant_awards["ban"] = 5 - grant_awards["pin"] = 1 - grant_awards["unpin"] = 1 - grant_awards["flairlock"] = 1 - elif u.patron == 5 or u.patron == 8: - grant_awards["shit"] = 20 - grant_awards["fireflies"] = 20 - grant_awards["train"] = 20 - grant_awards["ban"] = 10 - grant_awards["pin"] = 2 - grant_awards["unpin"] = 2 - grant_awards["flairlock"] = 2 + u.procoins += bc + send_notification(NOTIFICATIONS_ACCOUNT, u, f"You were given {procoins} Marseybux!") + g.db.add(u) - for name in grant_awards: - for count in range(grant_awards[name]): - - thing += 1 - - award = AwardRelationship( - id=thing, - user_id=u.id, - kind=name - ) - - g.db.add(award) - - text = "You were given the following awards:\n\n" - - for key, value in grant_awards.items(): - text += f" - **{value}** {AWARDS[key]['title']} {'Awards' if value != 1 else 'Award'}\n" - - send_notification(NOTIFICATIONS_ACCOUNT, u, text) - - - g.db.commit() - return {"message": "Monthly awards granted"} + g.db.commit() + return {"message": "Monthly coins granted"} @app.get('/admin/rules') @@ -415,76 +371,7 @@ def badge_grant_post(v): \n\n![]({new_badge.path}) \n\n{new_badge.name} """ - send_notification(NOTIFICATIONS_ACCOUNT, user, text) - - if badge_id in [21,22,23,24,25,28]: - user.patron = int(str(badge_id)[-1]) - - grant_awards = {} - - if badge_id == 21: - if user.discord_id: add_role(user, "1") - grant_awards["shit"] = 1 - grant_awards["fireflies"] = 1 - grant_awards["train"] = 1 - elif badge_id == 22: - if user.discord_id: add_role(user, "2") - grant_awards["shit"] = 2 - grant_awards["fireflies"] = 2 - grant_awards["train"] = 2 - grant_awards["ban"] = 1 - elif badge_id == 23: - if user.discord_id: add_role(user, "3") - grant_awards["shit"] = 5 - grant_awards["fireflies"] = 5 - grant_awards["train"] = 5 - grant_awards["ban"] = 2 - elif badge_id in [24, 28]: - if user.discord_id: add_role(user, "4") - grant_awards["shit"] = 10 - grant_awards["fireflies"] = 10 - grant_awards["train"] = 10 - grant_awards["ban"] = 5 - grant_awards["pin"] = 1 - grant_awards["unpin"] = 1 - grant_awards["flairlock"] = 1 - elif badge_id == 25: - if user.discord_id: add_role(user, "5") - grant_awards["shit"] = 20 - grant_awards["fireflies"] = 20 - grant_awards["train"] = 20 - grant_awards["ban"] = 10 - grant_awards["pin"] = 2 - grant_awards["unpin"] = 2 - grant_awards["flairlock"] = 2 - - if len(grant_awards): - - thing = g.db.query(AwardRelationship).order_by(AwardRelationship.id.desc()).first().id - - for name in grant_awards: - for count in range(grant_awards[name]): - - thing += 1 - - award = AwardRelationship( - id=thing, - user_id=user.id, - kind=name - ) - - g.db.add(award) - - text = "You were given the following awards:\n\n" - - for key, value in grant_awards.items(): - text += f" - **{value}** {AWARDS[key]['title']} {'Awards' if value != 1 else 'Award'}\n" - - send_notification(NOTIFICATIONS_ACCOUNT, user, text) - - - g.db.add(user) - + send_notification(NOTIFICATIONS_ACCOUNT, user, text) g.db.commit() return redirect("/admin/badge_grant") diff --git a/files/routes/awards.py b/files/routes/awards.py index 99d820d5d..00122d491 100755 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -335,11 +335,16 @@ def buy(v, award): elif v.patron == 4: price = int(price*0.75) else: price = int(price*0.70) - if v.coins < price: return {"error": "Not enough coins."}, 400 - v.coins -= price - v.coins_spent += price - g.db.add(v) + if request.values.get("mb"): + if v.procoins < price: return {"error": "Not enough marseybux."}, 400 + v.procoins -= price + else: + if v.coins < price: return {"error": "Not enough coins."}, 400 + v.coins -= price + v.coins_spent += price + g.db.add(v) + g.db.add(v) g.db.flush() thing = g.db.query(AwardRelationship).order_by(AwardRelationship.id.desc()).first().id thing += 1 diff --git a/files/routes/settings.py b/files/routes/settings.py index e2e754796..ea091aad1 100755 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -303,64 +303,21 @@ def gumroad(v): if v.patron == tier: return {"error": f"{patron} rewards already claimed"}, 400 v.patron = tier + if v.discord_id: add_role(v, f"{tier}") + + if v.patron == 1: procoins = 2000 + elif v.patron == 2: procoins = 5000 + elif v.patron == 3: procoins = 10000 + elif v.patron == 4: procoins = 25000 + elif v.patron == 5 or v.patron == 8: procoins = 50000 + + v.procoins += bc + send_notification(NOTIFICATIONS_ACCOUNT, v, f"You were given {procoins} Marseybux!") g.db.add(v) - grant_awards = {} - if tier == 1: - if v.discord_id: add_role(v, "1") - grant_awards["shit"] = 1 - grant_awards["fireflies"] = 1 - grant_awards["train"] = 1 - elif tier == 2: - if v.discord_id: add_role(v, "2") - grant_awards["shit"] = 2 - grant_awards["fireflies"] = 2 - grant_awards["train"] = 2 - grant_awards["ban"] = 1 - elif tier == 3: - if v.discord_id: add_role(v, "3") - grant_awards["shit"] = 5 - grant_awards["fireflies"] = 5 - grant_awards["train"] = 5 - grant_awards["ban"] = 2 - elif tier == 4: - if v.discord_id: add_role(v, "4") - grant_awards["shit"] = 10 - grant_awards["fireflies"] = 10 - grant_awards["train"] = 10 - grant_awards["ban"] = 5 - grant_awards["pin"] = 1 - grant_awards["unpin"] = 1 - grant_awards["flairlock"] = 1 - elif tier == 5 or tier == 8: - if v.discord_id: add_role(v, "5") - grant_awards["shit"] = 20 - grant_awards["fireflies"] = 20 - grant_awards["train"] = 20 - grant_awards["ban"] = 10 - grant_awards["pin"] = 2 - grant_awards["unpin"] = 2 - grant_awards["flairlock"] = 2 - - thing = g.db.query(AwardRelationship).order_by(AwardRelationship.id.desc()).first().id - - for name in grant_awards: - for count in range(grant_awards[name]): - - thing += 1 - - award = AwardRelationship( - id=thing, - user_id=v.id, - kind=name - ) - - g.db.add(award) if not v.has_badge(20+tier): - new_badge = Badge(badge_id=20+tier, - user_id=v.id, - ) + new_badge = Badge(badge_id=20+tier, user_id=v.id) g.db.add(new_badge) g.db.commit() diff --git a/files/templates/admin/awards.html b/files/templates/admin/awards.html index 0da7b9248..bfbcbd410 100755 --- a/files/templates/admin/awards.html +++ b/files/templates/admin/awards.html @@ -66,6 +66,6 @@

 	{% if v.id in [1,12,28,29,747,995,1480] %}
-		
Grant Monthly Awards
+
Grant Monthly Marseybux
{% endif %} {% endblock %} \ No newline at end of file diff --git a/files/templates/header.html b/files/templates/header.html index 588b06fc1..efa6dd250 100755 --- a/files/templates/header.html +++ b/files/templates/header.html @@ -109,7 +109,8 @@
{{v.username}}
-
{{v.coins}} {{'COINS_NAME' | app_config}}
+
{{v.coins}} {{'COINS_NAME' | app_config}}
+ {% if v.procoins %}
{{v.procoins}} Marseybux
{% endif %}
diff --git a/files/templates/shop.html b/files/templates/shop.html index 6d4a660d5..ad7c268be 100644 --- a/files/templates/shop.html +++ b/files/templates/shop.html @@ -85,7 +85,10 @@ {{a['title']}} {{a['price']}} {% set kind = a['kind'] %} - Buy + + Buy + {% if v.procoins and kind not in ["agendaposter","unban","grass"] %}Buy with Marseybux{% endif %} + {% endfor %} diff --git a/files/templates/userpage.html b/files/templates/userpage.html index af28c3d7f..c9c591f4b 100755 --- a/files/templates/userpage.html +++ b/files/templates/userpage.html @@ -130,6 +130,11 @@ {{u.coins}}    + {% if u.procoins %} + {{u.procoins}} +    + {% endif %} + {% if u.stored_subscriber_count >=1 and not u.is_nofollow %}{{u.stored_subscriber_count}} follower{{'s' if u.stored_subscriber_count != 1 else ''}}   {% endif %} joined {{u.created_date}} @@ -385,8 +390,13 @@ {% if u.customtitle %}

{% if u.quadrant %}{% endif %}{{u.customtitle | safe}}

{% endif %}
{{u.coins}} -    + + {% if u.procoins %} + {{u.procoins}} +    + {% endif %} + {% if u.stored_subscriber_count >=1 and not u.is_nofollow %}{{u.stored_subscriber_count}} follower{{'s' if u.stored_subscriber_count != 1 else ''}}   {% endif %} {% if "pcm" in request.host %}
Based count: {{u.basedcount}}