switch coins.py to use cron timers
This commit is contained in:
parent
80f0a3d94c
commit
13f2baf303
1 changed files with 4 additions and 6 deletions
|
@ -40,12 +40,6 @@ class CoinParseException(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class Module(ModuleManager.BaseModule):
|
class Module(ModuleManager.BaseModule):
|
||||||
def on_load(self):
|
|
||||||
self.timers.add("coin-interest", self._interest, INTEREST_INTERVAL,
|
|
||||||
time.time()+self._until_next_hour())
|
|
||||||
self.timers.add("coin-lottery", self._lottery, LOTTERY_INTERVAL,
|
|
||||||
time.time()+self._until_next_6_hour())
|
|
||||||
|
|
||||||
def _until_next_hour(self, now=None):
|
def _until_next_hour(self, now=None):
|
||||||
now = now or datetime.datetime.utcnow()
|
now = now or datetime.datetime.utcnow()
|
||||||
until_next_hour = 60-now.second
|
until_next_hour = 60-now.second
|
||||||
|
@ -440,6 +434,8 @@ class Module(ModuleManager.BaseModule):
|
||||||
"%s loses %s" % (choice, event["user"].nickname,
|
"%s loses %s" % (choice, event["user"].nickname,
|
||||||
str(coin_losses)))
|
str(coin_losses)))
|
||||||
|
|
||||||
|
@utils.hook("cron")
|
||||||
|
@utils.kwarg("schedule", "0 *")
|
||||||
def _interest(self, timer):
|
def _interest(self, timer):
|
||||||
for server in self.bot.servers.values():
|
for server in self.bot.servers.values():
|
||||||
if not server.get_setting("coin-interest", False):
|
if not server.get_setting("coin-interest", False):
|
||||||
|
@ -538,6 +534,8 @@ class Module(ModuleManager.BaseModule):
|
||||||
else:
|
else:
|
||||||
event["stderr"].write("There have been no lottery winners!")
|
event["stderr"].write("There have been no lottery winners!")
|
||||||
|
|
||||||
|
@utils.hook("cron")
|
||||||
|
@utils.kwarg("schedule", "0 */6")
|
||||||
def _lottery(self, timer):
|
def _lottery(self, timer):
|
||||||
for server in self.bot.servers.values():
|
for server in self.bot.servers.values():
|
||||||
lottery = server.get_setting("lottery", {})
|
lottery = server.get_setting("lottery", {})
|
||||||
|
|
Loading…
Reference in a new issue