diff --git a/Module.py b/Module.py index 2ea3625..2318992 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 shutdown(self): + """ + Do pre-deletion type cleanup. + + Implement this to close databases, write to disk, etc. + """ + def on_pubmsg(self, connection, event): """ Handle pubmsg events. Does some variable setup and initial sanity checking before diff --git a/modules/IrcAdmin.py b/modules/IrcAdmin.py index 2880087..e477242 100644 --- a/modules/IrcAdmin.py +++ b/modules/IrcAdmin.py @@ -105,6 +105,9 @@ class IrcAdmin(Module): def sub_quit_irc(self, connection, event, nick, userhost, replypath, what, admin_unlocked): whats = what.split(' ') + for module in self.modlist: + module.shutdown() + if replypath is not None: connection.privmsg(replypath, 'Quitting...') connection.quit(' '.join(whats[1:])) diff --git a/modules/MegaHAL.py b/modules/MegaHAL.py index 04f7d5e..4f30f82 100644 --- a/modules/MegaHAL.py +++ b/modules/MegaHAL.py @@ -41,6 +41,12 @@ class MegaHAL(Module): except NoOptionError: self.megahal = megahal.MegaHAL() + def shutdown(self): + """ + Close the megahal brain. + """ + self.megahal.close() + def reload(self, connection, event, nick, userhost, replypath, what, admin_unlocked): """ Broken. Don't do anything.