add unload method to IrcAdmin, which unloads a module
hopefully this all works right. i remove two known references to the object, and then call a del for good measure, which i think covers it?
This commit is contained in:
parent
2295f524d4
commit
ea0f795194
@ -81,6 +81,8 @@ class IrcAdmin(Module):
|
|||||||
return self.sub_load_module(connection, event, nick, userhost, replypath, what, admin_unlocked)
|
return self.sub_load_module(connection, event, nick, userhost, replypath, what, admin_unlocked)
|
||||||
elif whats[0] == 'reload' and admin_unlocked and len(whats) >= 2:
|
elif whats[0] == 'reload' and admin_unlocked and len(whats) >= 2:
|
||||||
return self.sub_reload_module(connection, event, nick, userhost, replypath, what, admin_unlocked)
|
return self.sub_reload_module(connection, event, nick, userhost, replypath, what, admin_unlocked)
|
||||||
|
elif whats[0] == 'unload' and admin_unlocked and len(whats) >= 2:
|
||||||
|
return self.sub_unload_module(connection, event, nick, userhost, replypath, what, admin_unlocked)
|
||||||
|
|
||||||
def sub_join_channel(self, connection, event, nick, userhost, replypath, what, admin_unlocked):
|
def sub_join_channel(self, connection, event, nick, userhost, replypath, what, admin_unlocked):
|
||||||
whats = what.split(' ')
|
whats = what.split(' ')
|
||||||
@ -192,6 +194,27 @@ class IrcAdmin(Module):
|
|||||||
module.reload()
|
module.reload()
|
||||||
return self.reply(connection, replypath, modname + ' reloaded.')
|
return self.reply(connection, replypath, modname + ' reloaded.')
|
||||||
|
|
||||||
|
def sub_unload_module(self, connection, event, nick, userhost, replypath, what, admin_unlocked):
|
||||||
|
"""
|
||||||
|
Attempt to unload and del a module if it's loaded.
|
||||||
|
"""
|
||||||
|
|
||||||
|
whats = what.split(' ')
|
||||||
|
|
||||||
|
modname = whats[1]
|
||||||
|
for module in self.modlist:
|
||||||
|
if modname == module.__class__.__name__:
|
||||||
|
# remove module references
|
||||||
|
self.modlist.remove(module)
|
||||||
|
module.unregister_handlers()
|
||||||
|
|
||||||
|
# del it
|
||||||
|
del module
|
||||||
|
return self.reply(connection, replypath, modname + ' unloaded.')
|
||||||
|
|
||||||
|
# guess it was never loaded
|
||||||
|
return self.reply(connection, replypath, modname + ' is not loaded.')
|
||||||
|
|
||||||
# Save the config file.
|
# Save the config file.
|
||||||
def save_config(self):
|
def save_config(self):
|
||||||
with open('dr.botzo.cfg', 'w') as cfg:
|
with open('dr.botzo.cfg', 'w') as cfg:
|
||||||
|
Loading…
Reference in New Issue
Block a user