mirror of
https://git.wownero.com/wownero/tippero.git
synced 2024-08-15 00:33:14 +00:00
Use decimal functions to read amounts/units from string inputs
This commit is contained in:
parent
8a81397a84
commit
d455985552
8 changed files with 18 additions and 16 deletions
|
@ -555,7 +555,7 @@ def Blackjack(link,cmd):
|
|||
return
|
||||
try:
|
||||
amount=float(cmd[1])
|
||||
units=long(amount*coinspecs.atomic_units)
|
||||
units=StringToUnits(cmd[1])
|
||||
except Exception,e:
|
||||
link.send("%s: usage: !blackjack amount" % link.user.nick)
|
||||
return
|
||||
|
|
|
@ -273,11 +273,10 @@ def Bet(link,cmd):
|
|||
link.send('usage: !bet [<event name>] <outcome> <amount>')
|
||||
return
|
||||
try:
|
||||
amount = float(amount)
|
||||
units = StringToUnits(amount)
|
||||
except Exception,e:
|
||||
link.send('usage: !bet [<event name>] <outcome> <amount>')
|
||||
return
|
||||
units = long(amount*coinspecs.atomic_units)
|
||||
if units <= 0:
|
||||
link.send("Invalid amount")
|
||||
return
|
||||
|
|
|
@ -49,7 +49,7 @@ def Dice(link,cmd):
|
|||
identity=link.identity()
|
||||
try:
|
||||
amount=float(cmd[1])
|
||||
units=long(amount*coinspecs.atomic_units)
|
||||
units=StringToUnits(cmd[1])
|
||||
multiplier = float(cmd[2])
|
||||
overunder=GetParam(cmd,3)
|
||||
except Exception,e:
|
||||
|
|
|
@ -63,11 +63,10 @@ def Tip(link,cmd):
|
|||
identity=link.identity()
|
||||
try:
|
||||
who=cmd[1]
|
||||
amount=float(cmd[2])
|
||||
units=StringToUnits(cmd[2])
|
||||
except Exception,e:
|
||||
link.send("Usage: tip nick amount")
|
||||
return
|
||||
units=long(amount*coinspecs.atomic_units)
|
||||
if units <= 0:
|
||||
link.send("Invalid amount")
|
||||
return
|
||||
|
@ -105,6 +104,7 @@ def Rain(link,cmd):
|
|||
|
||||
try:
|
||||
amount=float(cmd[1])
|
||||
units = StringToUnits(cmd[1])
|
||||
except Exception,e:
|
||||
link.send("Usage: rain amount [users]")
|
||||
return
|
||||
|
@ -122,7 +122,6 @@ def Rain(link,cmd):
|
|||
if users != None and users <= 0:
|
||||
link.send("Usage: rain amount [users]")
|
||||
return
|
||||
units = long(amount * coinspecs.atomic_units)
|
||||
|
||||
try:
|
||||
account = GetAccount(identity)
|
||||
|
@ -202,6 +201,7 @@ def RainActive(link,cmd):
|
|||
link.send("usage: !rainactive <amount> <hours> [<minfrac>]")
|
||||
return
|
||||
try:
|
||||
units=StringToUnits(amount)
|
||||
amount=float(amount)
|
||||
if amount <= 0:
|
||||
raise RuntimeError("")
|
||||
|
@ -227,8 +227,6 @@ def RainActive(link,cmd):
|
|||
else:
|
||||
minfrac = 0
|
||||
|
||||
units = long(amount * coinspecs.atomic_units)
|
||||
|
||||
try:
|
||||
account = GetAccount(link)
|
||||
balance = redis_hget("balances",account)
|
||||
|
|
|
@ -61,10 +61,9 @@ def Withdraw(link,cmd):
|
|||
amount = GetParam(cmd,2)
|
||||
if amount:
|
||||
try:
|
||||
famount=float(amount)
|
||||
if (famount < 0):
|
||||
amount = StringToUnits(amount)
|
||||
if (amount <= 0):
|
||||
raise RuntimeError("")
|
||||
amount = long(famount * coinspecs.atomic_units)
|
||||
amount += local_withdraw_fee
|
||||
except Exception,e:
|
||||
link.send("Invalid amount")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue