diff options
| author | 2018-10-12 18:07:23 +0100 | |
|---|---|---|
| committer | 2018-10-12 18:07:23 +0100 | |
| commit | 819f4e0680dc8225355924e87bc71938605b98f7 (patch) | |
| tree | 435f17eccda20a1723f51330ee0403668c76afcd /modules/coins.py | |
| parent | Add TimersContext, to be able to purge timers when modules are unloaded (diff) | |
Pass context-wrapped timers to each module, add ModuleManager.BaseModule.on_load
Diffstat (limited to 'modules/coins.py')
| -rw-r--r-- | modules/coins.py | 11 |
1 files changed, 5 insertions, 6 deletions
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): |
