diff --git a/files/classes/badges.py b/files/classes/badges.py index 82879a51d..3d2d5feaa 100644 --- a/files/classes/badges.py +++ b/files/classes/badges.py @@ -41,12 +41,13 @@ class Badge(Base): ti = self.user.agendaposter_expires_utc if ti: text = self.badge.description + " until " + datetime.utcfromtimestamp(ti).strftime('%Y-%m-%d %H:%M:%S') else: text = self.badge.description + " permanently" - elif self.badge_id in (94,95,96,97,98): + elif self.badge_id in (94,95,96,97,98,109): if self.badge_id == 94: ti = self.user.progressivestack elif self.badge_id == 95: ti = self.user.bird elif self.badge_id == 96: ti = self.user.flairchanged elif self.badge_id == 97: ti = self.user.longpost - else: ti = self.user.marseyawarded + elif self.badge_id == 98: ti = self.user.marseyawarded + elif self.badge_id == 109: ti = self.user.rehab text = self.badge.description + " until " + datetime.utcfromtimestamp(ti).strftime('%Y-%m-%d %H:%M:%S') elif self.description: text = self.description elif self.badge.description: text = self.badge.description diff --git a/files/classes/blackjack.py b/files/classes/blackjack.py index afc0a240e..6859cf172 100644 --- a/files/classes/blackjack.py +++ b/files/classes/blackjack.py @@ -54,6 +54,7 @@ def format_all(player_hand, dealer_hand, deck, status, wager): class Blackjack: command_word = "!blackjack" + casino_word = "!blackjackmb" minimum_bet = 100 maximum_bet = INFINITY @@ -94,9 +95,6 @@ class Blackjack: from_comment.blackjack_result = format_all( player_hand, dealer_hand, rest_of_deck, status, wager) - self.db.add(from_comment) - self.db.commit() - def player_hit(self, from_comment): player_hand, dealer_hand, deck, status, wager = from_comment.blackjack_result.split( "_") @@ -113,9 +111,6 @@ class Blackjack: from_comment.blackjack_result = format_all( player_hand, dealer_hand, deck, status, wager) - self.db.add(from_comment) - self.db.commit() - if (player_value == 21): self.player_stayed(from_comment) @@ -143,9 +138,6 @@ class Blackjack: from_comment.blackjack_result = format_all( player_hand, dealer_hand, deck, status, wager) - self.db.add(from_comment) - self.db.commit() - self.apply_game_result(from_comment, wager, status) def apply_game_result(self, from_comment, wager, result): @@ -161,7 +153,4 @@ class Blackjack: if (reward > 0): user = from_comment.author user.coins += reward - user.winnings += reward - - self.db.add(user) - self.db.commit() \ No newline at end of file + user.winnings += reward \ No newline at end of file diff --git a/files/classes/treasure.py b/files/classes/treasure.py index 0a808650a..295cc5bed 100644 --- a/files/classes/treasure.py +++ b/files/classes/treasure.py @@ -11,7 +11,7 @@ class Treasure: self.db = g.db def check_for_treasure(self, in_text, from_comment): - has_gamble_command = '!slots' in in_text or '!blackjack' in in_text + has_gamble_command = '!slots' in in_text or '!casino' in in_text or '!blackjack' in in_text if not has_gamble_command: seed = random.randint(1, 1000) diff --git a/files/classes/user.py b/files/classes/user.py index 374e28d70..eeb01f17e 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -50,6 +50,7 @@ class User(Base): verified = Column(String) verifiedcolor = Column(String) marseyawarded = Column(Integer) + rehab = Column(Integer) longpost = Column(Integer) winnings = Column(Integer, default=0) unblockable = Column(Boolean) diff --git a/files/helpers/const.py b/files/helpers/const.py index 9ecb29fca..6b5dba5df 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -356,6 +356,14 @@ AWARDS = { "color": "text-white", "price": 500 }, + "rehab": { + "kind": "rehab", + "title": "Rehab", + "description": "Prevents the user from gambling for 24 hours in a last ditch effort to save them from themself.", + "icon": "fas fa-dice-six", + "color": "text-black", + "price": 777 + }, "progressivestack": { "kind": "progressivestack", "title": "Progressive Stack", diff --git a/files/routes/awards.py b/files/routes/awards.py index 84b4fecd0..f7075ff1b 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -403,6 +403,14 @@ def award_post(pid, v): for c in post.comments: c.ghost = True g.db.add(c) + elif kind == "rehab": + if author.rehab: author.rehab += 86400 + else: author.rehab = int(time.time()) + 86400 + if not v.has_badge(109): + badge = Badge(user_id=v.id, badge_id=109) + g.db.add(badge) + g.db.flush() + 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 @@ -622,6 +630,14 @@ def award_comment(cid, v): elif kind == "ghosts": c.ghost = True g.db.add(c) + elif kind == "rehab": + if author.rehab: author.rehab += 86400 + else: author.rehab = int(time.time()) + 86400 + if not v.has_badge(109): + badge = Badge(user_id=v.id, badge_id=109) + g.db.add(badge) + g.db.flush() + 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 diff --git a/files/routes/comments.py b/files/routes/comments.py index 8c57732a8..e14d88f7a 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -202,7 +202,7 @@ def api_comment(v): process_image(filename) elif parent_post.id == 37833: try: - badge_def = loads(body.lower()) + badge_def = loads(body) name = badge_def["name"] badge = g.db.query(BadgeDef).filter_by(name=name).first() if not badge: @@ -589,11 +589,12 @@ def api_comment(v): c.upvotes += 1 g.db.add(c) - slots = Slots(g) - slots.check_for_slots_command(body, v, c) + if not v.rehab: + slots = Slots(g) + slots.check_for_slots_command(body, v, c) - blackjack = Blackjack(g) - blackjack.check_for_blackjack_command(body, v, c) + blackjack = Blackjack(g) + blackjack.check_for_blackjack_command(body, v, c) treasure = Treasure(g) treasure.check_for_treasure(body, c) diff --git a/files/routes/front.py b/files/routes/front.py index 2c74417ae..ac4720c59 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -244,6 +244,14 @@ def front_all(v): if badge: g.db.delete(badge) g.db.commit() + if v.rehab and v.rehab < time.time(): + v.rehab = None + send_repeatable_notification(v.id, "Your rehab has finished!") + g.db.add(v) + badge = v.has_badge(109) + if badge: g.db.delete(badge) + g.db.commit() + if request.headers.get("Authorization"): return {"data": [x.json for x in posts], "next_exists": next_exists} return render_template("home.html", v=v, listing=posts, next_exists=next_exists, sort=sort, t=t, page=page) diff --git a/files/routes/posts.py b/files/routes/posts.py index fa0740f6f..5235d226e 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -667,7 +667,7 @@ def thumbnail_thread(pid): db.add(post) db.commit() - if SITE == 'rdrama.net' and random.random() < 0.05: + if SITE == 'rdrama.net' and random.random() < 0.02: for t in ("submission","comment"): for term in ('rdrama','freeghettohoes.biz','marsey'): for i in requests.get(f'https://api.pushshift.io/reddit/{t}/search?html_decode=true&q={term}&size=10').json()["data"]: diff --git a/files/routes/users.py b/files/routes/users.py index 46f2eabb8..3f3b3ddb6 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -71,9 +71,14 @@ def upvoters(v, username): users2 = [] for user in users: users2.append((user, votes[user.id])) - users = sorted(users2, key=lambda x: x[1], reverse=True)[:25] + users = sorted(users2, key=lambda x: x[1], reverse=True) + + try: + pos = [x[0].id for x in users].index(v.id) + pos = (pos+1, users[pos][1]) + except: pos = (len(users)+1, 0) - return render_template("voters.html", v=v, users=users, name='Up', name2=f'@{username} biggest simps') + return render_template("voters.html", v=v, users=users[:25], pos=pos, name='Up', name2=f'@{username} biggest simps') @app.get("/@/downvoters") @auth_required @@ -90,9 +95,14 @@ def downvoters(v, username): users2 = [] for user in users: users2.append((user, votes[user.id])) - users = sorted(users2, key=lambda x: x[1], reverse=True)[:25] + users = sorted(users2, key=lambda x: x[1], reverse=True) + + try: + pos = [x[0].id for x in users].index(v.id) + pos = (pos+1, users[pos][1]) + except: pos = (len(users)+1, 0) - return render_template("voters.html", v=v, users=users, name='Down', name2=f'@{username} biggest haters') + return render_template("voters.html", v=v, users=users[:25], pos=pos, name='Down', name2=f'@{username} biggest haters') @app.get("/@/upvoting") @auth_required @@ -109,9 +119,14 @@ def upvoting(v, username): users2 = [] for user in users: users2.append((user, votes[user.id])) - users = sorted(users2, key=lambda x: x[1], reverse=True)[:25] + users = sorted(users2, key=lambda x: x[1], reverse=True) + + try: + pos = [x[0].id for x in users].index(v.id) + pos = (pos+1, users[pos][1]) + except: pos = (len(users)+1, 0) - return render_template("voters.html", v=v, users=users, name='Up', name2=f'Who @{username} simps for') + return render_template("voters.html", v=v, users=users[:25], pos=pos, name='Up', name2=f'Who @{username} simps for') @app.get("/@/downvoting") @auth_required @@ -128,9 +143,14 @@ def downvoting(v, username): users2 = [] for user in users: users2.append((user, votes[user.id])) - users = sorted(users2, key=lambda x: x[1], reverse=True)[:25] + users = sorted(users2, key=lambda x: x[1], reverse=True) + + try: + pos = [x[0].id for x in users].index(v.id) + pos = (pos+1, users[pos][1]) + except: pos = (len(users)+1, 0) - return render_template("voters.html", v=v, users=users, name='Down', name2=f'Who @{username} hates') + return render_template("voters.html", v=v, users=users[:25], pos=pos, name='Down', name2=f'Who @{username} hates') @app.post("/pay_rent") @limiter.limit("1/second;30/minute;200/hour;1000/day") diff --git a/files/templates/authforms.html b/files/templates/authforms.html index 14e11ae79..5ed9100eb 100644 --- a/files/templates/authforms.html +++ b/files/templates/authforms.html @@ -15,7 +15,7 @@ {% if v %} - + {% if v.agendaposter %} - + {% endif %} diff --git a/files/templates/comments.html b/files/templates/comments.html index 8dad4283e..ce612c7d0 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -878,10 +878,6 @@ object-fit: cover; } - .text-black { - color: var(--black); - } - .smolbtn { font-weight: 600; font-size: .9rem; diff --git a/files/templates/default.html b/files/templates/default.html index d8cbcc408..d5d0a88b9 100644 --- a/files/templates/default.html +++ b/files/templates/default.html @@ -7,7 +7,7 @@ {% if v %} - + {% if v.agendaposter %} - + {% endif %} diff --git a/files/templates/log.html b/files/templates/log.html index a1f66ae27..a310d6eee 100644 --- a/files/templates/log.html +++ b/files/templates/log.html @@ -6,7 +6,7 @@ {% block content %} {% if v %} - + {% if v.agendaposter %} - + {% endif %}
diff --git a/files/templates/login.html b/files/templates/login.html index ae2eee108..e059c63bb 100644 --- a/files/templates/login.html +++ b/files/templates/login.html @@ -18,7 +18,7 @@ {% endblock %} - + diff --git a/files/templates/login_2fa.html b/files/templates/login_2fa.html index 00d81014d..b707b734d 100644 --- a/files/templates/login_2fa.html +++ b/files/templates/login_2fa.html @@ -14,7 +14,7 @@ 2-Step Login - {{SITE_NAME}} - + diff --git a/files/templates/settings.html b/files/templates/settings.html index 3aeb96250..b8a04a4d0 100644 --- a/files/templates/settings.html +++ b/files/templates/settings.html @@ -34,7 +34,7 @@ - + {% if v.agendaposter %} - + {% else %} - + {% endif %} diff --git a/files/templates/sign_up.html b/files/templates/sign_up.html index d01540885..a6cf61b70 100644 --- a/files/templates/sign_up.html +++ b/files/templates/sign_up.html @@ -31,7 +31,7 @@ {% if ref_user %}{{ref_user.username}} invites you to {{SITE_NAME}}{% else %}Sign up - {{SITE_NAME}}{% endif %} - + diff --git a/files/templates/sign_up_failed_ref.html b/files/templates/sign_up_failed_ref.html index 253849c68..b0f90967f 100644 --- a/files/templates/sign_up_failed_ref.html +++ b/files/templates/sign_up_failed_ref.html @@ -32,7 +32,7 @@ {% if ref_user %}{{ref_user.username}} invites you to {{SITE_NAME}}{% else %}{{SITE_NAME}}{% endif %} - + diff --git a/files/templates/submission_listing.html b/files/templates/submission_listing.html index 7440d1834..3085c20dd 100644 --- a/files/templates/submission_listing.html +++ b/files/templates/submission_listing.html @@ -659,10 +659,6 @@ object-fit: cover; } - .text-black { - color: var(--black); - } - .smolbtn { font-weight: 600; font-size: .9rem; diff --git a/files/templates/submit.html b/files/templates/submit.html index aedd96363..3a5400df2 100644 --- a/files/templates/submit.html +++ b/files/templates/submit.html @@ -26,7 +26,7 @@ {% block stylesheets %} {% if v %} - + {% if v.agendaposter %} - + {% endif %} {% endblock %} diff --git a/files/templates/voters.html b/files/templates/voters.html index 4389637d3..ae02e4016 100644 --- a/files/templates/voters.html +++ b/files/templates/voters.html @@ -16,13 +16,26 @@ {% for user in users %} - + {{loop.index}} @{{user[0].username}}'s profile picture{{user[0].username}} {{user[1]}} {% endfor %} +{% if pos and (pos[0] > 25 or not pos[1]) %} + + {{pos[0]}} + @{{v.username}}'s profile picture{{v.username}} + {{pos[1]}} + +{% endif %} + {% endblock %} \ No newline at end of file