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):
|
def quit_irc(self, connection, msg):
|
||||||
for module in self.modlist:
|
for module in self.modlist:
|
||||||
|
module.save()
|
||||||
module.shutdown()
|
module.shutdown()
|
||||||
|
|
||||||
connection.quit(msg)
|
connection.quit(msg)
|
||||||
self.save_config()
|
print(self.save_config())
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
def save_config(self):
|
def save_config(self):
|
||||||
with open('dr.botzo.cfg', 'w') as cfg:
|
with open('dr.botzo.cfg', 'w') as cfg:
|
||||||
self.config.write(cfg)
|
self.config.write(cfg)
|
||||||
|
|
||||||
for module in self.modlist:
|
return 'Saved config.'
|
||||||
module.save()
|
|
||||||
|
|
||||||
return 'Saved.'
|
|
||||||
|
|
||||||
def load_module(self, modname):
|
def load_module(self, modname):
|
||||||
"""Load a module (in both the python and dr.botzo sense) if not
|
"""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:
|
for module in self.modlist:
|
||||||
if modname == module.__class__.__name__:
|
if modname == module.__class__.__name__:
|
||||||
# do anything the module needs to do to clean up
|
# do anything the module needs to do to clean up
|
||||||
|
module.save()
|
||||||
module.shutdown()
|
module.shutdown()
|
||||||
|
|
||||||
# remove module references
|
# remove module references
|
||||||
|
@ -325,6 +324,10 @@ class DrBotIRC(irclib.IRC):
|
||||||
|
|
||||||
# SIGINT signal handler
|
# SIGINT signal handler
|
||||||
def sigint_handler(self, signal, frame):
|
def sigint_handler(self, signal, frame):
|
||||||
|
for module in self.modlist:
|
||||||
|
module.save()
|
||||||
|
module.shutdown()
|
||||||
|
|
||||||
print(self.save_config())
|
print(self.save_config())
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue