diff --git a/tipbot/betutils.py b/tipbot/betutils.py index 1c26427..2b67c3d 100644 --- a/tipbot/betutils.py +++ b/tipbot/betutils.py @@ -43,10 +43,15 @@ def IsBetValid(link,amount,minbet,maxbet,potential_loss,max_loss,max_loss_ratio) units=long(amount*coinspecs.atomic_units) if units <= 0: return False, "Invalid amount" - if amount > maxbet: + if maxbet != None and amount > maxbet: return False, "Max bet is %s" % AmountToString(maxbet * coinspecs.atomic_units) - if amount < minbet: + if minbet != None and amount < minbet: return False, "Min bet is %s" % AmountToString(minbet * coinspecs.atomic_units) + + enough, reason = IsPlayerBalanceAtLeast(link,units) + if not enough: + return False, reason + if potential_loss > 0: if potential_loss > max_loss: return False, "Max potential loss is %s" % AmountToString(max_loss * coinspecs.atomic_units) diff --git a/tipbot/modules/blackjack.py b/tipbot/modules/blackjack.py index d292d8f..aa36c2e 100644 --- a/tipbot/modules/blackjack.py +++ b/tipbot/modules/blackjack.py @@ -575,10 +575,6 @@ def Blackjack(link,cmd): log_info("Dice: %s's bet refused: %s" % (identity, reason)) link.send("%s: %s" % (link.user.nick, reason)) return - enough, reason = IsPlayerBalanceAtLeast(link,total_units_wagered) - if not enough: - link.send("%s: %s" % (link.user.nick, reason)) - return try: rolls, seed = GetNewShuffleSeed(link) diff --git a/tipbot/modules/dice.py b/tipbot/modules/dice.py index 8bdf621..0178fff 100644 --- a/tipbot/modules/dice.py +++ b/tipbot/modules/dice.py @@ -74,20 +74,6 @@ def Dice(link,cmd): link.send("%s: %s" % (link.user.nick, reason)) return - try: - balance = redis_hget("balances",identity) - if balance == None: - balance = 0 - balance=long(balance) - if units > balance: - log_error ('%s does not have enough balance' % identity) - link.send("You only have %s" % (AmountToString(balance))) - return - except Exception,e: - log_error ('failed to query balance') - link.send("Failed to query balance") - return - try: rolls, roll = Roll(link) except: