remotes/1693045480750635534/spooky-22
Aevann1 2022-04-10 01:07:03 +02:00
parent 727de75175
commit 15a02cf3cd
7 changed files with 33 additions and 40 deletions

View File

@ -723,7 +723,7 @@ snappy_url_regex = re.compile('<a href=\"(https?:\/\/[a-z]{1,20}\.[\w:~,()\-.#&\
email_regex = re.compile('([A-Za-z0-9]+[.-_])*[A-Za-z0-9]+@[A-Za-z0-9-]+(\.[A-Z|a-z]{2,100})+', flags=re.A)
reddit_post_regex = re.compile('(https:\/\/old\.reddit\.com\/r\/\w{1,30}\/comments\/[a-z0-9]+)[\w\-.#&/=?@%+]{5,250}', flags=re.A)
reddit_post_regex = re.compile('https:\/\/old\.reddit\.com\/r\/\w{1,30}\/comments\/([a-z0-9]+)(\/\w{0,100})?', flags=re.A)
utm_regex = re.compile('utm_[a-z]+=[a-z0-9_]+&', flags=re.A)
utm_regex2 = re.compile('[?&]utm_[a-z]+=[a-z0-9_]+', flags=re.A)

View File

@ -58,30 +58,22 @@ def buy(v, award):
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}")
old_badge = v.has_badge(72)
if old_badge: g.db.delete(old_badge)
elif v.coins_spent >= 500000 and not v.has_badge(72):
new_badge = Badge(badge_id=72, 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}")
old_badge = v.has_badge(71)
if old_badge: g.db.delete(old_badge)
elif v.coins_spent >= 250000 and not v.has_badge(71):
new_badge = Badge(badge_id=71, 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}")
old_badge = v.has_badge(70)
if old_badge: g.db.delete(old_badge)
elif v.coins_spent >= 100000 and not v.has_badge(70):
new_badge = Badge(badge_id=70, 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}")
old_badge = v.has_badge(69)
if old_badge: g.db.delete(old_badge)
elif v.coins_spent >= 10000 and not v.has_badge(69):
new_badge = Badge(badge_id=69, user_id=v.id)
g.db.add(new_badge)

View File

@ -289,9 +289,6 @@ def api_comment(v):
text = f"@AutoJanny has given you the following profile badge:\n\n![]({new_badge.path})\n\n{new_badge.name}"
send_notification(user.id, text)
old_badge = user.has_badge(17)
if old_badge: g.db.delete(old_badge)
elif all_by_author < 10 and not user.has_badge(17):
new_badge = Badge(badge_id=17, user_id=user.id)

View File

@ -310,22 +310,6 @@ def sign_up_post(v):
ref_id = int(request.values.get("referred_by", 0))
if ref_id:
ref_user = g.db.query(User).filter_by(id=ref_id).one_or_none()
if ref_user:
if ref_user.referral_count and not ref_user.has_badge(10):
new_badge = Badge(user_id=ref_user.id, badge_id=10)
g.db.add(new_badge)
if ref_user.referral_count > 9 and not ref_user.has_badge(11):
new_badge = Badge(user_id=ref_user.id, badge_id=11)
g.db.add(new_badge)
if ref_user.referral_count > 99 and not ref_user.has_badge(12):
new_badge = Badge(user_id=ref_user.id, badge_id=12)
g.db.add(new_badge)
id_1 = g.db.query(User.id).filter_by(id=9).count()
users_count = g.db.query(User.id).count()
if id_1 == 0 and users_count == 8:
@ -349,6 +333,25 @@ def sign_up_post(v):
g.db.add(new_user)
g.db.flush()
if ref_id:
ref_user = g.db.query(User).filter_by(id=ref_id).one_or_none()
if ref_user:
if ref_user.referral_count and not ref_user.has_badge(10):
new_badge = Badge(user_id=ref_user.id, badge_id=10)
g.db.add(new_badge)
g.db.flush()
send_notification(ref_user.id, f"@AutoJanny has given you the following profile badge:\n\n![]({new_badge.path})\n\n{new_badge.name}")
if ref_user.referral_count >= 10 and not ref_user.has_badge(11):
new_badge = Badge(user_id=ref_user.id, badge_id=11)
g.db.add(new_badge)
g.db.flush()
send_notification(ref_user.id, f"@AutoJanny has given you the following profile badge:\n\n![]({new_badge.path})\n\n{new_badge.name}")
if ref_user.referral_count >= 100 and not ref_user.has_badge(12):
new_badge = Badge(user_id=ref_user.id, badge_id=12)
g.db.add(new_badge)
g.db.flush()
send_notification(ref_user.id, f"@AutoJanny has given you the following profile badge:\n\n![]({new_badge.path})\n\n{new_badge.name}")
check_for_alts(new_user.id)

View File

@ -892,19 +892,19 @@ def submit_post(v, sub=None):
url = urlunparse(new_url)
search_url = url.replace('%', '')
search_url = reddit_post_regex.sub(r'\1%', search_url)
search_url = search_url.replace('\\', '').replace('_', '\_').strip()
if url.endswith('/'): url = url[:-1]
if reddit_post_regex.fullmatch(url):
url = reddit_post_regex.sub(r'https://old.reddit.com/\1', url)
search_url = url.replace('%', '').replace('\\', '').replace('_', '\_').strip()
repost = g.db.query(Submission).filter(
Submission.url.ilike(search_url),
Submission.deleted_utc == 0,
Submission.is_banned == False
).first()
if repost: return redirect(repost.permalink)
domain_obj = get_domain(domain)
if not domain_obj: domain_obj = get_domain(domain+parsed_url.path)
@ -1067,6 +1067,11 @@ def submit_post(v, sub=None):
is_bot = bool(request.headers.get("Authorization")) or (SITE == 'pcmemes.net' and v.id == SNAPPY_ID)
if request.values.get("ghost") and v.coins >= 100:
v.coins -= 100
ghost = True
else: ghost = False
post = Submission(
private=bool(request.values.get("private","")),
club=club,
@ -1082,7 +1087,7 @@ def submit_post(v, sub=None):
title=title[:500],
title_html=title_html,
sub=sub,
ghost=bool(request.values.get("ghost",""))
ghost=ghost
)
g.db.add(post)

View File

@ -432,10 +432,6 @@ def gumroad(v):
existing = g.db.query(User.id).filter(User.email == v.email, User.is_activated == True, User.patron >= tier).one_or_none()
if existing: return {"error": f"{patron} rewards already claimed on another account"}, 400
if v.patron:
badge = v.has_badge(20+v.patron)
if badge: g.db.delete(badge)
v.patron = tier
if v.discord_id: add_role(v, f"{tier}")

View File

@ -187,8 +187,8 @@
{% endif %}
<div class="custom-control custom-checkbox">
<input onchange='draft(this);' autocomplete="off" type="checkbox" class="custom-control-input" id="ghost" name="ghost">
<label class="custom-control-label" for="ghost">Ghost Thread</label>
<input onchange='draft(this);' autocomplete="off" type="checkbox" class="custom-control-input" id="ghost" name="ghost" {% if v.coins < 100 %}disabled{% endif %}>
<label class="custom-control-label" for="ghost">Ghost Thread (cost: 100 coins)</label>
</div>
<pre>