marseybux
This commit is contained in:
parent
96e98c0acd
commit
e9c15e2f9c
9 changed files with 53 additions and 186 deletions
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"python.pythonPath": "/bin/python3"
|
||||
}
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
\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")
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -66,6 +66,6 @@
|
|||
|
||||
<pre></pre>
|
||||
{% if v.id in [1,12,28,29,747,995,1480] %}
|
||||
<div><a class="btn btn-success" href="javascript:void(0)" onclick="post_toast('/admin/monthly')">Grant Monthly Awards</a></div>
|
||||
<div><a class="btn btn-success" href="javascript:void(0)" onclick="post_toast('/admin/monthly')">Grant Monthly Marseybux</a></div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
|
@ -109,7 +109,8 @@
|
|||
<div><img loading="lazy" src="{{v.profile_url}}" class="profile-pic-35"></div>
|
||||
<div class="text-left pl-2">
|
||||
<div style="color: #{{v.namecolor}}" class="text-small font-weight-bold {% if v.patron %}patron{% endif %}"><span {% if v.patron %}class="patron" style="background-color:#{{v.namecolor}};"{% endif %}>{{v.username}}</span></div>
|
||||
<div class="text-small-extra text-primary"><img class="mr-1 ml-1" data-bs-toggle="tooltip" data-bs-placement="bottom" height="13" src="/assets/images/emojis/marseycoin.webp" title="" data-bs-original-title="{{'COINS_NAME' | app_config}}" aria-label="{{'COINS_NAME' | app_config}}"><span id="user-coins-amount">{{v.coins}}</span> {{'COINS_NAME' | app_config}}</div>
|
||||
<div class="text-small-extra text-primary"><img class="mr-1 ml-1" data-bs-toggle="tooltip" data-bs-placement="bottom" height="13" src="/assets/images/emojis/marseycoin.webp" title="" data-bs-original-title="{{'COINS_NAME' | app_config}}" aria-label="{{'COINS_NAME' | app_config}}"><span>{{v.coins}}</span> {{'COINS_NAME' | app_config}}</div>
|
||||
{% if v.procoins %}<div class="text-small-extra text-primary"><img class="mr-1 ml-1" data-bs-toggle="tooltip" data-bs-placement="bottom" height="13" src="/assets/images/emojis/marseybux.webp" title="" data-bs-original-title="Marseybux" aria-label="Marseybux"><span>{{v.procoins}}</span> Marseybux</div>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
|
|
|
@ -85,7 +85,10 @@
|
|||
<td style="font-weight: bold">{{a['title']}}</td>
|
||||
<td style="font-weight: bold">{{a['price']}}</td>
|
||||
{% set kind = a['kind'] %}
|
||||
<td style="font-weight: bold"><a class="btn btn-success {% if v.coins < a['price'] %}disabled{% endif %}" href="javascript:void(0)" onclick="post_toast('/buy/{{kind}}')">Buy</a></td>
|
||||
<td style="font-weight: bold">
|
||||
<a class="btn btn-success {% if v.coins < a['price'] %}disabled{% endif %}" href="javascript:void(0)" onclick="post_toast('/buy/{{kind}}')">Buy</a>
|
||||
{% if v.procoins and kind not in ["agendaposter","unban","grass"] %}<a class="btn btn-success {% if v.procoins < a['price'] %}disabled{% endif %}" href="javascript:void(0)" onclick="post_toast('/buy/{{kind}}?mb=true')">Buy with Marseybux</a>{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
|
|
@ -130,6 +130,11 @@
|
|||
<span id="profile-coins-amount">{{u.coins}}</span>
|
||||
<img class="ml-1 mb-1" data-bs-toggle="tooltip" data-bs-placement="bottom" title="" data-bs-original-title="{{'COINS_NAME' | app_config}}" height="20" src="/assets/images/emojis/marseycoin.webp">
|
||||
|
||||
{% if u.procoins %}
|
||||
<span>{{u.procoins}}</span>
|
||||
<img class="ml-1 mb-1" data-bs-toggle="tooltip" data-bs-placement="bottom" title="" data-bs-original-title="Marseybux" height="20" src="/assets/images/emojis/marseybux.webp">
|
||||
{% endif %}
|
||||
|
||||
{% if u.stored_subscriber_count >=1 and not u.is_nofollow %}<a href="/@{{u.username}}/followers">{{u.stored_subscriber_count}} follower{{'s' if u.stored_subscriber_count != 1 else ''}}</a> {% endif %}
|
||||
joined <span data-bs-toggle="tooltip" data-bs-placement="bottom" title="" data-bs-original-title="{{u.created_datetime}}">{{u.created_date}}</span>
|
||||
</div>
|
||||
|
@ -385,8 +390,13 @@
|
|||
{% if u.customtitle %}<p style="color: #{{u.titlecolor}}">{% if u.quadrant %}<img loading="lazy" height="20" src="/assets/images/PCM/quadrants/{{u.quadrant}}.gif">{% endif %}{{u.customtitle | safe}}</p>{% endif %}
|
||||
<div class="font-weight-normal">
|
||||
<span id="profile-coins-amount-mobile" class="font-weight-bold">{{u.coins}}</span>
|
||||
|
||||
<img class="ml-1 mb-1" data-bs-toggle="tooltip" data-bs-placement="bottom" title="" data-bs-original-title="{{'COINS_NAME' | app_config}}" height="15" src="/assets/images/emojis/marseycoin.webp">
|
||||
|
||||
{% if u.procoins %}
|
||||
<span class="font-weight-bold">{{u.procoins}}</span>
|
||||
<img class="ml-1 mb-1" data-bs-toggle="tooltip" data-bs-placement="bottom" title="" data-bs-original-title="Marseybux" height="15" src="/assets/images/emojis/marseybux.webp">
|
||||
{% endif %}
|
||||
|
||||
{% if u.stored_subscriber_count >=1 and not u.is_nofollow %}<a href="/@{{u.username}}/followers" class="font-weight-bold">{{u.stored_subscriber_count}} follower{{'s' if u.stored_subscriber_count != 1 else ''}}</a> {% endif %}
|
||||
{% if "pcm" in request.host %}
|
||||
<br>Based count: {{u.basedcount}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue