From b7cf524e9869828ff85954cb731f7fee98bee8d9 Mon Sep 17 00:00:00 2001 From: jesopo Date: Fri, 31 Aug 2018 12:55:52 +0100 Subject: Give modules event objects with "context"s, to facilitate purging all the event hooks for a module --- modules/coins.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'modules/coins.py') diff --git a/modules/coins.py b/modules/coins.py index 4fa0377e..307f171f 100644 --- a/modules/coins.py +++ b/modules/coins.py @@ -26,26 +26,26 @@ THIRD_COLUMN = list(range(1, 37))[2::3] REGEX_STREET = re.compile("street([1-9]|1[0-2])$") class Module(object): - def __init__(self, bot): + def __init__(self, bot, events): self.bot = bot - bot.events.on("received.command.coins").hook(self.coins, + events.on("received.command.coins").hook(self.coins, help="Show how many coins you have") - bot.events.on("received").on("command").on("resetcoins").hook( + events.on("received").on("command").on("resetcoins").hook( self.reset_coins, permission="resetcoins", min_args=1, help= "Reset a specified user's coins to %s" % str(DECIMAL_ZERO), usage="") - bot.events.on("received.command.richest").hook( + events.on("received.command.richest").hook( self.richest, help="Show the top 10 richest users") - bot.events.on("received.command.redeemcoins").hook( + events.on("received.command.redeemcoins").hook( self.redeem_coins, help="Redeem free coins") - bot.events.on("received.command.flip").hook(self.flip, + events.on("received.command.flip").hook(self.flip, help="Bet coins on a coin flip", usage= "heads|tails ", min_args=2, protect_registered=True) - bot.events.on("received.command.sendcoins").hook( + events.on("received.command.sendcoins").hook( self.send, min_args=2, help="Send coins to a user", usage=" ", authenticated=True) - bot.events.on("received.command.roulette").hook( + events.on("received.command.roulette").hook( self.roulette, min_args=2, help="Spin the roulette wheel", usage=" ", protect_registered=True) @@ -53,7 +53,7 @@ class Module(object): until_next_hour = 60-now.second until_next_hour += ((60-(now.minute+1))*60) - bot.events.on("timer").on("coin-interest").hook(self.interest) + events.on("timer").on("coin-interest").hook(self.interest) bot.add_timer("coin-interest", INTEREST_INTERVAL, persist=False, next_due=time.time()+until_next_hour) -- cgit v1.3.1-10-gc9f91