aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorGravatar jesopo2018-10-13 16:47:46 +0100
committerGravatar jesopo2018-10-13 16:47:46 +0100
commitb2f948a73b4137c3b4fa3a80764ae1702b7aaa2d (patch)
tree49a6dcd38cdbef2ac23e3756551a1be22c9db19b /modules
parentTypo in src/Timers.py, 'conteext' -> 'context' (diff)
signature
Add !totalcoins in modules/coins.py, to check what the total coins in
circulation is
Diffstat (limited to 'modules')
-rw-r--r--modules/coins.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/modules/coins.py b/modules/coins.py
index 904947f8..3da26851 100644
--- a/modules/coins.py
+++ b/modules/coins.py
@@ -64,6 +64,18 @@ class Module(ModuleManager.BaseModule):
event["stdout"].write("The Bank has %s coins" %
"{0:.2f}".format(self._get_pool(event["server"])))
+ @utils.hook("received.command.totalcoins")
+ def total_coins(self, event):
+ all_coins = event["server"].get_all_user_settings("coins", [])
+ all_coins = list(filter(lambda coin: decimal.Decimal(coin[1]),
+ all_coins))
+ all_coins = [decimal.Decimal(coin[1]) for coin in all_coins]
+ all_coins = sum(all_coins)
+ pool = self._get_pool(event["server"])
+
+ event["stdout"].write("Total coins: %s" % "{0:.2f}".format(
+ pool+all_coins))
+
@utils.hook("received.command.coins")
def coins(self, event):
"""