have all modules run a shutdown() when quitting, use it to have MegaHAL close the brain
This commit is contained in:
parent
cb54abf2b8
commit
f590daf5cd
@ -92,6 +92,13 @@ class Module(object):
|
|||||||
self.server.remove_global_handler('pubmsg', self.on_pubmsg)
|
self.server.remove_global_handler('pubmsg', self.on_pubmsg)
|
||||||
self.server.remove_global_handler('privmsg', self.on_privmsg)
|
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):
|
def on_pubmsg(self, connection, event):
|
||||||
"""
|
"""
|
||||||
Handle pubmsg events. Does some variable setup and initial sanity checking before
|
Handle pubmsg events. Does some variable setup and initial sanity checking before
|
||||||
|
@ -105,6 +105,9 @@ class IrcAdmin(Module):
|
|||||||
def sub_quit_irc(self, connection, event, nick, userhost, replypath, what, admin_unlocked):
|
def sub_quit_irc(self, connection, event, nick, userhost, replypath, what, admin_unlocked):
|
||||||
whats = what.split(' ')
|
whats = what.split(' ')
|
||||||
|
|
||||||
|
for module in self.modlist:
|
||||||
|
module.shutdown()
|
||||||
|
|
||||||
if replypath is not None:
|
if replypath is not None:
|
||||||
connection.privmsg(replypath, 'Quitting...')
|
connection.privmsg(replypath, 'Quitting...')
|
||||||
connection.quit(' '.join(whats[1:]))
|
connection.quit(' '.join(whats[1:]))
|
||||||
|
@ -41,6 +41,12 @@ class MegaHAL(Module):
|
|||||||
except NoOptionError:
|
except NoOptionError:
|
||||||
self.megahal = megahal.MegaHAL()
|
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):
|
def reload(self, connection, event, nick, userhost, replypath, what, admin_unlocked):
|
||||||
"""
|
"""
|
||||||
Broken. Don't do anything.
|
Broken. Don't do anything.
|
||||||
|
Loading…
Reference in New Issue
Block a user