forked from MarseyWorld/MarseyWorld
use transactions table in rdrama
parent
59fe09d0af
commit
b7e4f27f65
|
@ -13,9 +13,7 @@ export TURNSTILE_SECRET="blahblahblah"
|
|||
export YOUTUBE_KEY="blahblahblah"
|
||||
export VAPID_PUBLIC_KEY="blahblahblah"
|
||||
export VAPID_PRIVATE_KEY="blahblahblah"
|
||||
export GUMROAD_TOKEN="blahblahblah"
|
||||
export GUMROAD_LINK="blahblahblah"
|
||||
export GUMROAD_ID="blahblahblah"
|
||||
export CF_KEY="blahblahblah"
|
||||
export CF_ZONE="blahblahblah"
|
||||
export DEBIAN_FRONTEND="noninteractive"
|
||||
|
|
|
@ -42,9 +42,7 @@ TURNSTILE_SECRET = environ.get("TURNSTILE_SECRET").strip()
|
|||
YOUTUBE_KEY = environ.get("YOUTUBE_KEY").strip()
|
||||
VAPID_PUBLIC_KEY = environ.get("VAPID_PUBLIC_KEY").strip()
|
||||
VAPID_PRIVATE_KEY = environ.get("VAPID_PRIVATE_KEY").strip()
|
||||
GUMROAD_TOKEN = environ.get("GUMROAD_TOKEN").strip()
|
||||
GUMROAD_LINK = environ.get("GUMROAD_LINK").strip()
|
||||
GUMROAD_ID = environ.get("GUMROAD_ID").strip()
|
||||
CF_KEY = environ.get("CF_KEY").strip()
|
||||
CF_ZONE = environ.get("CF_ZONE").strip()
|
||||
GLOBAL = environ.get("GLOBAL", "").strip()
|
||||
|
@ -615,7 +613,6 @@ HOLE_COST = 0
|
|||
HOLE_INACTIVITY_DELETION = False
|
||||
|
||||
PRIVILEGED_USER_BOTS = ()
|
||||
GUMROAD_MESSY = ()
|
||||
|
||||
AUTOJANNY_ID = 1
|
||||
SNAPPY_ID = 2
|
||||
|
@ -713,7 +710,6 @@ if SITE == 'rdrama.net':
|
|||
HOLE_INACTIVITY_DELETION = True
|
||||
|
||||
PRIVILEGED_USER_BOTS = (12125,16049)
|
||||
GUMROAD_MESSY = (1379)
|
||||
|
||||
AUTOJANNY_ID = 1046
|
||||
SNAPPY_ID = 261
|
||||
|
|
|
@ -186,11 +186,6 @@ MODACTION_TYPES = {
|
|||
"icon": 'fa-file-signature',
|
||||
"color": 'bg-success'
|
||||
},
|
||||
'monthly': {
|
||||
"str": 'distributed monthly marseybux',
|
||||
"icon": 'fa-sack-dollar',
|
||||
"color": 'bg-success'
|
||||
},
|
||||
'move_hole': {
|
||||
"str": 'changed hole of {self.target_link}',
|
||||
"icon": 'fa-manhole',
|
||||
|
|
|
@ -42,9 +42,6 @@ def cron(every_5m, every_1h, every_1d, every_1mo):
|
|||
site_stats = stats.stats(SITE_NAME)
|
||||
cache.set(f'{SITE}_stats', site_stats)
|
||||
|
||||
if every_1mo and not KOFI_LINK:
|
||||
_give_monthly_marseybux_task()
|
||||
|
||||
g.db.commit()
|
||||
g.db.close()
|
||||
del g.db
|
||||
|
@ -109,53 +106,3 @@ def _sub_inactive_purge_task():
|
|||
g.db.delete(x)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def _give_monthly_marseybux_task():
|
||||
month = datetime.datetime.now() + datetime.timedelta(days=5)
|
||||
month = month.strftime('%B')
|
||||
|
||||
data = {'access_token': GUMROAD_TOKEN}
|
||||
|
||||
emails = [x['email'] for x in requests.get(f'https://api.gumroad.com/v2/products/{GUMROAD_ID}/subscribers', data=data, timeout=5).json()["subscribers"]]
|
||||
|
||||
def give_marseybux(u):
|
||||
marseybux_reward = marseybux_li[u.patron]
|
||||
u.pay_account('marseybux', marseybux_reward)
|
||||
send_repeatable_notification(u.id, f"@AutoJanny has given you {marseybux_reward} Marseybux for the month of {month}! You can use them to buy awards or hats in the [shop](/shop) or gamble them in the [casino](/casino).")
|
||||
|
||||
for badge in g.db.query(Badge).filter(Badge.badge_id > 20, Badge.badge_id < 28).all():
|
||||
g.db.delete(badge)
|
||||
|
||||
for u in g.db.query(User).filter(User.patron > 0, User.patron_utc == 0).all():
|
||||
g.db.add(u)
|
||||
if u.admin_level or u.id == GUMROAD_MESSY:
|
||||
give_marseybux(u)
|
||||
badge_grant(badge_id=20+u.patron, user=u, notify=False)
|
||||
elif u.email and u.is_activated and u.email.lower() in emails:
|
||||
data = {'access_token': GUMROAD_TOKEN, 'email': u.email}
|
||||
try:
|
||||
response = requests.get('https://api.gumroad.com/v2/sales', data=data, timeout=5).json()["sales"]
|
||||
except:
|
||||
print(f'Marseybux monthly granting failed for @{u.username}', flush=True)
|
||||
u.patron = 0
|
||||
continue
|
||||
|
||||
if len(response) == 0:
|
||||
u.patron = 0
|
||||
continue
|
||||
response = [x for x in response if x['variants_and_quantity']][0]
|
||||
tier = tiers[response["variants_and_quantity"]]
|
||||
u.patron = tier
|
||||
badge_grant(badge_id=20+tier, user=u, notify=False)
|
||||
give_marseybux(u)
|
||||
else:
|
||||
u.patron = 0
|
||||
|
||||
ma = ModAction(
|
||||
kind="monthly",
|
||||
user_id=AUTOJANNY_ID,
|
||||
)
|
||||
g.db.add(ma)
|
||||
|
||||
return True
|
||||
|
|
|
@ -400,43 +400,6 @@ def namecolor(v):
|
|||
def themecolor(v):
|
||||
return set_color(v, "themecolor", request.values.get("themecolor"))
|
||||
|
||||
@app.post("/settings/gumroad")
|
||||
@limiter.limit(DEFAULT_RATELIMIT_SLOWER)
|
||||
@limiter.limit(DEFAULT_RATELIMIT_SLOWER, key_func=get_ID)
|
||||
@auth_required
|
||||
def settings_gumroad(v):
|
||||
if GUMROAD_TOKEN == DEFAULT_CONFIG_VALUE: abort(404)
|
||||
if not (v.email and v.is_activated):
|
||||
abort(400, f"You must have a verified email to verify {patron} status and claim your rewards!")
|
||||
|
||||
data = {'access_token': GUMROAD_TOKEN, 'email': v.email}
|
||||
response = requests.get('https://api.gumroad.com/v2/sales', data=data, timeout=5).json()["sales"]
|
||||
|
||||
if len(response) == 0: abort(404, "Email not found")
|
||||
|
||||
response = [x for x in response if x['variants_and_quantity']]
|
||||
response = response[0]
|
||||
tier = tiers[response["variants_and_quantity"]]
|
||||
if v.patron == tier: abort(400, f"{patron} rewards already claimed!")
|
||||
|
||||
marseybux = marseybux_li[tier] - marseybux_li[v.patron]
|
||||
if marseybux < 0: abort(400, f"{patron} rewards already claimed!")
|
||||
|
||||
existing = g.db.query(User.id).filter(User.email == v.email, User.is_activated == True, User.patron >= tier).first()
|
||||
if existing: abort(400, f"{patron} rewards already claimed on another account")
|
||||
|
||||
v.patron = tier
|
||||
|
||||
v.pay_account('marseybux', marseybux)
|
||||
send_repeatable_notification(v.id, f"You have received {marseybux} Marseybux! You can use them to buy awards or hats in the [shop](/shop) or gamble them in the [casino](/casino).")
|
||||
|
||||
g.db.add(v)
|
||||
|
||||
badge_grant(badge_id=20+tier, user=v)
|
||||
|
||||
|
||||
return {"message": f"{patron} rewards claimed!"}
|
||||
|
||||
@app.post("/settings/titlecolor")
|
||||
@limiter.limit(DEFAULT_RATELIMIT_SLOWER)
|
||||
@limiter.limit(DEFAULT_RATELIMIT_SLOWER, key_func=get_ID)
|
||||
|
|
|
@ -1361,21 +1361,19 @@ def gumroad():
|
|||
g.db.add(transaction)
|
||||
|
||||
user = g.db.query(User).filter_by(email=email, is_activated=True).order_by(User.truescore.desc()).first()
|
||||
# if user:
|
||||
# claim_rewards(user)
|
||||
if user:
|
||||
claim_rewards(user)
|
||||
|
||||
return ''
|
||||
|
||||
|
||||
|
||||
|
||||
@app.post("/settings/kofi")
|
||||
@app.post("/settings/claim_rewards")
|
||||
@limiter.limit(DEFAULT_RATELIMIT_SLOWER)
|
||||
@limiter.limit(DEFAULT_RATELIMIT_SLOWER, key_func=get_ID)
|
||||
@auth_required
|
||||
def settings_kofi(v:User):
|
||||
if not KOFI_TOKEN: abort(404)
|
||||
|
||||
def claim_rewards(v:User):
|
||||
if not (v.email and v.is_activated):
|
||||
abort(400, f"You must have a verified email to verify {patron} status and claim your rewards!")
|
||||
|
||||
|
|
|
@ -35,11 +35,7 @@
|
|||
<div class="footer">
|
||||
<div class="d-flex">
|
||||
{% if FEATURES['MARSEYBUX'] %}
|
||||
{% if KOFI_TOKEN %}
|
||||
<button type="button" class="btn btn-success" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/settings/kofi')">Claim {{patron}} rewards</button>
|
||||
{% else %}
|
||||
<button type="button" class="btn btn-success" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/settings/gumroad')">Claim {{patron}} rewards</button>
|
||||
{% endif %}
|
||||
<button type="button" class="btn btn-success" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/settings/claim_rewards')">Claim {{patron}} rewards</button>
|
||||
{% endif %}
|
||||
{% if v.email %}
|
||||
<input autocomplete="off" class="btn btn-primary ml-auto" type="submit" data-nonce="{{g.nonce}}" data-onclick="disable(this)" value="Update email">
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
delete from modactions where kind='monthly';
|
Loading…
Reference in New Issue