diff --git a/files/helpers/actions.py b/files/helpers/actions.py index 04f6ccbda..bbdc1d6e1 100644 --- a/files/helpers/actions.py +++ b/files/helpers/actions.py @@ -93,6 +93,8 @@ def execute_snappy(post, v): ) g.db.add(vote) post.upvotes += 1 + elif body == '!slots': + body = f'!slots{snappy.coins}' body += "\n\n" @@ -169,6 +171,9 @@ def execute_snappy(post, v): snappy.coins += 1 g.db.add(snappy) + if c.body.startswith('!slots'): + execute_slots_command(snappy, c) + if FEATURES['PINS'] and (body.startswith(':#marseypin:') or body.startswith(':#marseypin2:')): post.stickied = "Snappy" post.stickied_utc = int(time.time()) + 3600 diff --git a/files/helpers/slots.py b/files/helpers/slots.py index 8ece9a6da..902f22c44 100644 --- a/files/helpers/slots.py +++ b/files/helpers/slots.py @@ -113,3 +113,34 @@ def determine_payout(): def shuffle(stuff): random.shuffle(stuff) return stuff + + +def execute_slots_command(u, c): + body = c.body.lower() + + if u.rehab: + abort(403, "You are under Rehab award effect!") + + if '!slotsmb' in body: + command_word = '!slotsmb' + currency = 'procoins' + else: + command_word = '!slots' + currency = 'coins' + + wager = body.split(command_word)[1].split()[0] + + try: + wager = int(wager) + except: + abort(400, "Invalid wager.") + + if wager < 100: + abort(400, f"Wager must be 100 {currency} or more") + + if (currency == "coins" and wager > u.coins) or (currency == "procoins" and wager > u.procoins): + abort(400, f"Not enough {currency} to make that bet") + + game_id, game_state = casino_slot_pull(v, wager, currency) + + c.casino_game_id = game_id diff --git a/files/routes/comments.py b/files/routes/comments.py index 88353e4f9..cf9ff365d 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -357,34 +357,8 @@ def comment(v): parent_post.comment_count += 1 g.db.add(parent_post) - body = c.body.lower() - if FEATURES['GAMBLING'] and '!slots' in body: - if v.rehab: - abort(403, "You are under Rehab award effect!") - - if '!slotsmb' in body: - command_word = '!slotsmb' - currency = 'procoins' - else: - command_word = '!slots' - currency = 'coins' - - wager = body.split(command_word)[1].split()[0] - - try: - wager = int(wager) - except: - abort(400, "Invalid wager.") - - if wager < 100: - abort(400, f"Wager must be 100 {currency} or more") - - if (currency == "coins" and wager > v.coins) or (currency == "procoins" and wager > v.procoins): - abort(400, f"Not enough {currency} to make that bet") - - game_id, game_state = casino_slot_pull(v, wager, currency) - - c.casino_game_id = game_id + if FEATURES['GAMBLING'] and '!slots' in c.body.lower(): + execute_slots_command(v, c) g.db.flush() diff --git a/snappy_rDrama.txt b/snappy_rDrama.txt index f3d7127ba..3a33dc1f9 100644 --- a/snappy_rDrama.txt +++ b/snappy_rDrama.txt @@ -3144,4 +3144,6 @@ On top of that, you're going to have be very careful with what you do and how, b This is going to be interesting to put it mildly no matter how it goes. I mean you did fuck with a major court case that has eyes on it all over the country, and they've already getting cops involved and looks like the FBI is joining too. -I'm just saying it won't be pleasant. \ No newline at end of file +I'm just saying it won't be pleasant. +{[para]} +!slots