From 7ea61f423d3466e2ffac8f19ba59e57e70c859a1 Mon Sep 17 00:00:00 2001 From: TLSM Date: Fri, 7 Oct 2022 20:31:46 -0400 Subject: [PATCH] PCM: disable gambling; extend FEATURES['GAMBLING']. --- files/helpers/const.py | 2 ++ files/helpers/cron.py | 5 ++-- files/routes/casino.py | 52 +++++++++++++++++++++++++++---------- files/templates/header.html | 4 +-- 4 files changed, 45 insertions(+), 18 deletions(-) diff --git a/files/helpers/const.py b/files/helpers/const.py index 262876cf57..1460bd0328 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -338,6 +338,7 @@ if SITE == 'rdrama.net': elif SITE == 'pcmemes.net': PIN_LIMIT = 10 FEATURES['REPOST_DETECTION'] = False + FEATURES['GAMBLING'] = False POST_RATE_LIMIT = '1/second;4/minute;20/hour;100/day' HOLE_COST = 2000 @@ -356,6 +357,7 @@ elif SITE == 'pcmemes.net': WELCOME_MSG = "Welcome to pcmemes.net! Don't forget to turn off the slur filter [here](/settings/content#slurreplacer)" + CASINO_ENABLED = False LOTTERY_TICKET_COST = 12 LOTTERY_SINK_RATE = -8 diff --git a/files/helpers/cron.py b/files/helpers/cron.py index 10c9ca52ea..2dd3a89187 100644 --- a/files/helpers/cron.py +++ b/files/helpers/cron.py @@ -28,8 +28,9 @@ def cron(every_5m, every_1h, every_1d, every_1mo): g.db = db_session() if every_5m: - lottery.check_if_end_lottery_task() - spin_roulette_wheel() + if FEATURES['GAMBLING']: + lottery.check_if_end_lottery_task() + spin_roulette_wheel() offsitementions.offsite_mentions_task() if SITE == 'pcmemes.net': route_static.live_cached() diff --git a/files/routes/casino.py b/files/routes/casino.py index 99c58a03c1..7053de0f51 100644 --- a/files/routes/casino.py +++ b/files/routes/casino.py @@ -15,7 +15,9 @@ from files.helpers.lottery import * @limiter.limit("100/minute;2000/hour;12000/day") @auth_required def casino(v): - if v.rehab: + if not FEATURES['GAMBLING']: + abort(404) + elif v.rehab: return render_template("casino/rehab.html", v=v) return render_template("casino.html", v=v) @@ -25,9 +27,11 @@ def casino(v): @limiter.limit("100/minute;2000/hour;12000/day") @auth_required def casino_game_page(v, game): - if v.rehab: + if not FEATURES['GAMBLING']: + abort(404) + elif v.rehab: return render_template("casino/rehab.html", v=v) - if game not in CASINO_GAME_KINDS: + elif game not in CASINO_GAME_KINDS: abort(404) feed = json.dumps(get_game_feed(game)) @@ -52,9 +56,11 @@ def casino_game_page(v, game): @limiter.limit("100/minute;2000/hour;12000/day") @auth_required def casino_game_feed(v, game): - if v.rehab: + if not FEATURES['GAMBLING']: + abort(404) + elif v.rehab: return {"error": "You are under Rehab award effect!"}, 400 - if game not in CASINO_GAME_KINDS: + elif game not in CASINO_GAME_KINDS: abort(404) feed = get_game_feed(game) @@ -66,7 +72,9 @@ def casino_game_feed(v, game): @limiter.limit("100/minute;2000/hour;12000/day") @auth_required def lottershe(v): - if v.rehab: + if not FEATURES['GAMBLING']: + abort(404) + elif v.rehab: return render_template("casino/rehab.html", v=v) participants = get_users_participating_in_lottery() @@ -77,7 +85,9 @@ def lottershe(v): @limiter.limit("100/minute;2000/hour;12000/day") @auth_required def pull_slots(v): - if v.rehab: + if not FEATURES['GAMBLING']: + abort(404) + elif v.rehab: return {"error": "You are under Rehab award effect!"}, 400 try: @@ -106,7 +116,9 @@ def pull_slots(v): @limiter.limit("100/minute;2000/hour;12000/day") @auth_required def blackjack_deal_to_player(v): - if v.rehab: + if not FEATURES['GAMBLING']: + abort(404) + elif v.rehab: return {"error": "You are under Rehab award effect!"}, 400 try: @@ -125,7 +137,9 @@ def blackjack_deal_to_player(v): @limiter.limit("100/minute;2000/hour;12000/day") @auth_required def blackjack_player_hit(v): - if v.rehab: + if not FEATURES['GAMBLING']: + abort(404) + elif v.rehab: return {"error": "You are under Rehab award effect!"}, 400 try: @@ -140,7 +154,9 @@ def blackjack_player_hit(v): @limiter.limit("100/minute;2000/hour;12000/day") @auth_required def blackjack_player_stay(v): - if v.rehab: + if not FEATURES['GAMBLING']: + abort(404) + elif v.rehab: return {"error": "You are under Rehab award effect!"}, 400 try: @@ -155,7 +171,9 @@ def blackjack_player_stay(v): @limiter.limit("100/minute;2000/hour;12000/day") @auth_required def blackjack_player_doubled_down(v): - if v.rehab: + if not FEATURES['GAMBLING']: + abort(404) + elif v.rehab: return {"error": "You are under Rehab award effect!"}, 400 try: @@ -170,7 +188,9 @@ def blackjack_player_doubled_down(v): @limiter.limit("100/minute;2000/hour;12000/day") @auth_required def blackjack_player_bought_insurance(v): - if v.rehab: + if not FEATURES['GAMBLING']: + abort(404) + elif v.rehab: return {"error": "You are under Rehab award effect!"}, 400 try: @@ -185,7 +205,9 @@ def blackjack_player_bought_insurance(v): @limiter.limit("100/minute;2000/hour;12000/day") @auth_required def roulette_get_bets(v): - if v.rehab: + if not FEATURES['GAMBLING']: + abort(404) + elif v.rehab: return {"error": "You are under Rehab award effect!"}, 400 bets = get_roulette_bets() @@ -197,7 +219,9 @@ def roulette_get_bets(v): @limiter.limit("100/minute;2000/hour;12000/day") @auth_required def roulette_player_placed_bet(v): - if v.rehab: + if not FEATURES['GAMBLING']: + abort(404) + elif v.rehab: return {"error": "You are under Rehab award effect!"}, 400 try: diff --git a/files/templates/header.html b/files/templates/header.html index 4a574bb471..6d6ad13417 100644 --- a/files/templates/header.html +++ b/files/templates/header.html @@ -128,7 +128,7 @@ - {% if v and CASINO_ENABLED %} + {% if v and CASINO_ENABLED and FEATURES['GAMBLING'] %} @@ -194,7 +194,7 @@ - {% if CASINO_ENABLED %} + {% if CASINO_ENABLED and FEATURES['GAMBLING'] %}