diff --git a/files/classes/user.py b/files/classes/user.py index fa1b7e543..839015367 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -127,6 +127,7 @@ class User(Base): original_username = deferred(Column(String)) referred_by = Column(Integer, ForeignKey("users.id")) subs_created = Column(Integer, default=0) + can_gamble = Column(Boolean, default=True) currently_held_lottery_tickets = Column(Integer, default=0) total_held_lottery_tickets = Column(Integer, default=0) total_lottery_winnings = Column(Integer, default=0) diff --git a/files/helpers/blackjack.py b/files/helpers/blackjack.py index d560aad86..c0c753059 100644 --- a/files/helpers/blackjack.py +++ b/files/helpers/blackjack.py @@ -51,6 +51,9 @@ def format_all(player_hand, dealer_hand, deck, status, wager, kind, is_insured=0 def check_for_blackjack_commands(in_text, from_user, from_comment): + if not from_user.can_gamble: + return + for command_word in (coins_command_word, marseybux_command_word): currency_prop = "coins" if command_word == coins_command_word else "procoins" currency_value = getattr(from_user, currency_prop, 0) diff --git a/files/helpers/slots.py b/files/helpers/slots.py index c9083c49a..55a0c0078 100644 --- a/files/helpers/slots.py +++ b/files/helpers/slots.py @@ -19,6 +19,9 @@ def shuffle(stuff): return stuff def check_for_slots_command(in_text, from_user, from_comment): + if not from_user.can_gamble: + return + in_text = in_text.lower() if command_word in in_text: for word in in_text.split(): diff --git a/files/helpers/treasure.py b/files/helpers/treasure.py index a17f2f277..e432b2eab 100644 --- a/files/helpers/treasure.py +++ b/files/helpers/treasure.py @@ -10,6 +10,11 @@ standard_max = 100 lotterizer_rate = 33 def check_for_treasure(in_text, from_comment): + user = from_comment.author + + if not user.can_gamble: + return + if '!slots' not in in_text and '!blackjack' not in in_text and '!wordle' not in in_text: seed = randint(1, 1000) is_special = seed == 1000 @@ -21,14 +26,11 @@ def check_for_treasure(in_text, from_comment): elif is_standard: amount = randint(standard_min, standard_max) if randint(1, 100) > 90: - user = from_comment.author if amount > user.coins: amount = user.coins amount = -amount if amount != 0: - user = from_comment.author - if amount > 0: active_lottery = get_active_lottery() lottery_tickets_seed = randint(1, 100) diff --git a/files/helpers/wrappers.py b/files/helpers/wrappers.py index b57299d9e..f57601a08 100644 --- a/files/helpers/wrappers.py +++ b/files/helpers/wrappers.py @@ -144,6 +144,7 @@ def lottery_required(f): v = get_logged_in_user() if not LOTTERY_ENABLED: abort(404) + if v and not v.can_gamble: abort(403) return make_response(f(v=v)) diff --git a/files/routes/settings.py b/files/routes/settings.py index e1ad2e761..2dd3b81a4 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -83,6 +83,10 @@ def settings_profile_post(v): updated = True v.newtabexternal = request.values.get("newtabexternal") == 'true' + elif request.values.get("can_gamble", v.can_gamble) != v.can_gamble: + updated = True + v.can_gamble = request.values.get("can_gamble") == 'true' + elif request.values.get("nitter", v.nitter) != v.nitter: updated = True v.nitter = request.values.get("nitter") == 'true' diff --git a/files/templates/header.html b/files/templates/header.html index 4a3378ad4..fad937881 100644 --- a/files/templates/header.html +++ b/files/templates/header.html @@ -89,7 +89,7 @@ {%- endif %} - {% if v and LOTTERY_ENABLED %} + {% if v and v.can_gamble and LOTTERY_ENABLED %} - {% if LOTTERY_ENABLED %} + {% if v.can_gamble and LOTTERY_ENABLED %}