From 819f4e0680dc8225355924e87bc71938605b98f7 Mon Sep 17 00:00:00 2001 From: jesopo Date: Fri, 12 Oct 2018 18:07:23 +0100 Subject: Pass context-wrapped timers to each module, add ModuleManager.BaseModule.on_load --- modules/coins.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'modules/coins.py') diff --git a/modules/coins.py b/modules/coins.py index 813ca779..87053001 100644 --- a/modules/coins.py +++ b/modules/coins.py @@ -1,5 +1,5 @@ import datetime, decimal, functools, math, re, secrets, time -from src import utils +from src import ModuleManager, utils SIDES = {"heads": 0, "tails": 1} DEFAULT_REDEEM_DELAY = 600 # 600 seconds, 10 minutes @@ -30,12 +30,11 @@ 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, events, exports): - self.bot = bot - bot.timers.add("coin-interest", INTEREST_INTERVAL, +class Module(ModuleManager.BaseModule): + def on_load(self): + self.timers.add("coin-interest", INTEREST_INTERVAL, time.time()+self._until_next_hour()) - bot.timers.add("coin-lottery", LOTTERY_INTERVAL, + self.timers.add("coin-lottery", LOTTERY_INTERVAL, time.time()+self._until_next_6_hour()) def _until_next_hour(self, now=None): -- cgit v1.3.1-10-gc9f91