aboutsummaryrefslogtreecommitdiff
path: root/modules/database_backup.py
diff options
context:
space:
mode:
authorGravatar jesopo2018-10-12 18:07:23 +0100
committerGravatar jesopo2018-10-12 18:07:23 +0100
commit819f4e0680dc8225355924e87bc71938605b98f7 (patch)
tree435f17eccda20a1723f51330ee0403668c76afcd /modules/database_backup.py
parentAdd TimersContext, to be able to purge timers when modules are unloaded (diff)
signature
Pass context-wrapped timers to each module, add ModuleManager.BaseModule.on_load
Diffstat (limited to 'modules/database_backup.py')
-rw-r--r--modules/database_backup.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/modules/database_backup.py b/modules/database_backup.py
index 4f7e6395..55f18a13 100644
--- a/modules/database_backup.py
+++ b/modules/database_backup.py
@@ -1,17 +1,16 @@
import datetime, glob, os, shutil, time
-from src import utils
+from src import ModuleManager, utils
BACKUP_INTERVAL = 60*60 # 1 hour
BACKUP_COUNT = 5
-class Module(object):
- def __init__(self, bot, events, exports):
- self.bot = bot
+class Module(ModuleManager.BaseModule):
+ def on_load(self):
now = datetime.datetime.now()
until_next_hour = 60-now.second
until_next_hour += ((60-(now.minute+1))*60)
- bot.timers.add("database-backup", BACKUP_INTERVAL,
+ self.timers.add("database-backup", BACKUP_INTERVAL,
time.time()+until_next_hour)
@utils.hook("timer.database-backup")