make the module saving a bit more consistent
This commit is contained in:
parent
88d2a530c3
commit
faf37447cf
13
DrBotIRC.py
13
DrBotIRC.py
@ -239,20 +239,18 @@ class DrBotIRC(irclib.IRC):
|
||||
|
||||
def quit_irc(self, connection, msg):
|
||||
for module in self.modlist:
|
||||
module.save()
|
||||
module.shutdown()
|
||||
|
||||
connection.quit(msg)
|
||||
self.save_config()
|
||||
print(self.save_config())
|
||||
sys.exit()
|
||||
|
||||
def save_config(self):
|
||||
with open('dr.botzo.cfg', 'w') as cfg:
|
||||
self.config.write(cfg)
|
||||
|
||||
for module in self.modlist:
|
||||
module.save()
|
||||
|
||||
return 'Saved.'
|
||||
return 'Saved config.'
|
||||
|
||||
def load_module(self, modname):
|
||||
"""Load a module (in both the python and dr.botzo sense) if not
|
||||
@ -289,6 +287,7 @@ class DrBotIRC(irclib.IRC):
|
||||
for module in self.modlist:
|
||||
if modname == module.__class__.__name__:
|
||||
# do anything the module needs to do to clean up
|
||||
module.save()
|
||||
module.shutdown()
|
||||
|
||||
# remove module references
|
||||
@ -325,6 +324,10 @@ class DrBotIRC(irclib.IRC):
|
||||
|
||||
# SIGINT signal handler
|
||||
def sigint_handler(self, signal, frame):
|
||||
for module in self.modlist:
|
||||
module.save()
|
||||
module.shutdown()
|
||||
|
||||
print(self.save_config())
|
||||
sys.exit()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user