Add another control to prevent coin duplication if someone manages to send coins

to themselves
This commit is contained in:
jesopo 2018-09-05 12:58:30 +01:00
parent f2aeaf7797
commit 12143af562

View file

@ -188,9 +188,13 @@ class Module(object):
event["stderr"].write("You can only send coins to users that " event["stderr"].write("You can only send coins to users that "
"have had coins before") "have had coins before")
return return
target_user_coins = decimal.Decimal(target_user_coins)
event["user"].set_setting("coins", str(new_user_coins)) event["user"].set_setting("coins", str(new_user_coins))
# get target_user_coins again, just in case *somehow* someone's
# sending coins to themselves.
target_user_coins = target_user.get_setting("coins", None)
target_user_coins = decimal.Decimal(target_user_coins)
target_user.set_setting("coins", str(target_user_coins+send_amount)) target_user.set_setting("coins", str(target_user_coins+send_amount))
event["stdout"].write("%s sent %s coins to %s" % ( event["stdout"].write("%s sent %s coins to %s" % (