From 12143af562c021d83a96470e65275abf70576702 Mon Sep 17 00:00:00 2001 From: jesopo Date: Wed, 5 Sep 2018 12:58:30 +0100 Subject: [PATCH] Add another control to prevent coin duplication if someone manages to send coins to themselves --- modules/coins.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/coins.py b/modules/coins.py index 735d404d..efb60edd 100644 --- a/modules/coins.py +++ b/modules/coins.py @@ -188,9 +188,13 @@ class Module(object): event["stderr"].write("You can only send coins to users that " "have had coins before") return - target_user_coins = decimal.Decimal(target_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)) event["stdout"].write("%s sent %s coins to %s" % (