Correctly access bot_settings in Timers.py

This commit is contained in:
jesopo 2018-09-28 17:01:20 +01:00
parent fe1b479b2c
commit c5c2c50bc4
2 changed files with 5 additions and 4 deletions

View file

@ -28,7 +28,8 @@ class Timer(object):
return self._done
class Timers(object):
def __init__(self, events, log):
def __init__(self, database, events, log):
self.database = database
self.events = events
self.log = log
self.timers = []
@ -40,12 +41,12 @@ class Timers(object):
"next-due"], id, False, timer["kwargs"])
def _persist(self, timer):
self.set_setting("timer-%s" % timer.id, {
self.database.bot_settings.set("timer-%s" % timer.id, {
"name": timer.name, "delay": timer.delay,
"next-due": timer.next_due, "kwargs": timer.kwargs})
def _remove(self, timer):
self.timers.remove(timer)
self.del_setting("timer-%s" % timer.id)
self.database.bot_settings.delete("timer-%s" % timer.id)
def add(self, name, delay, next_due=None, **kwargs):
self._add(name, delay, next_due, None, False, kwargs)

View file

@ -35,7 +35,7 @@ config = Config.Config(args.config)
database = Database.Database(log, args.database)
events = events = EventManager.EventHook(log)
exports = exports = Exports.Exports()
timers = Timers.Timers(events, log)
timers = Timers.Timers(database, events, log)
line_handler = IRCLineHandler.LineHandler(events, timers)
modules = modules = ModuleManager.ModuleManager(events, exports, config, log,
os.path.join(directory, "modules"))