diff --git a/Module.py b/Module.py index a8c2bcf..3270eb7 100644 --- a/Module.py +++ b/Module.py @@ -92,6 +92,13 @@ class Module(object): self.server.remove_global_handler('pubmsg', self.on_pubmsg) self.server.remove_global_handler('privmsg', self.on_privmsg) + def save(self): + """ + Save whatever the module may need to save. Sync files, etc. + + Implement this if you need it. + """ + def shutdown(self): """ Do pre-deletion type cleanup. diff --git a/modules/IrcAdmin.py b/modules/IrcAdmin.py index c273cbb..e205c21 100644 --- a/modules/IrcAdmin.py +++ b/modules/IrcAdmin.py @@ -143,7 +143,11 @@ class IrcAdmin(Module): def sub_save_config(self, connection, event, nick, userhost, replypath, what, admin_unlocked): with open('dr.botzo.cfg', 'w') as cfg: self.config.write(cfg) - replystr = 'Saved config file.' + + for module in self.modlist: + module.save() + + replystr = 'Saved.' return self.reply(connection, replypath, replystr) def sub_change_nick(self, connection, event, nick, userhost, replypath, what, admin_unlocked): diff --git a/modules/MegaHAL.py b/modules/MegaHAL.py index c6e830e..8b3a217 100644 --- a/modules/MegaHAL.py +++ b/modules/MegaHAL.py @@ -37,9 +37,15 @@ class MegaHAL(Module): mh_python.initbrain() + def save(self): + """ + Sync the megahal brain. + """ + mh_python.cleanup() + def shutdown(self): """ - Close the megahal brain. + Sync the megahal brain. """ mh_python.cleanup()