mirror of
https://github.com/jlu5/PyLink.git
synced 2025-05-05 22:27:24 +02:00
coreplugin: fix unload not clearing defined commands
This commit is contained in:
parent
03790b5939
commit
fb496554a6
@ -347,18 +347,21 @@ def unload(irc, source, args):
|
|||||||
log.info('(%s) Unloading plugin %r for %s', irc.name, name, irc.getHostmask(source))
|
log.info('(%s) Unloading plugin %r for %s', irc.name, name, irc.getHostmask(source))
|
||||||
pl = world.plugins[name]
|
pl = world.plugins[name]
|
||||||
log.debug('sys.getrefcount of plugin %s is %s', pl, sys.getrefcount(pl))
|
log.debug('sys.getrefcount of plugin %s is %s', pl, sys.getrefcount(pl))
|
||||||
# Remove any command functions set by the plugin.
|
|
||||||
for cmdname, cmdfuncs in world.commands.copy().items():
|
# Remove any command functions defined by the plugin.
|
||||||
|
for cmdname, cmdfuncs in world.services['pylink'].commands.copy().items():
|
||||||
log.debug('cmdname=%s, cmdfuncs=%s', cmdname, cmdfuncs)
|
log.debug('cmdname=%s, cmdfuncs=%s', cmdname, cmdfuncs)
|
||||||
|
|
||||||
for cmdfunc in cmdfuncs:
|
for cmdfunc in cmdfuncs:
|
||||||
log.debug('__module__ of cmdfunc %s is %s', cmdfunc, cmdfunc.__module__)
|
log.debug('__module__ of cmdfunc %s is %s', cmdfunc, cmdfunc.__module__)
|
||||||
if cmdfunc.__module__ == name:
|
if cmdfunc.__module__ == name:
|
||||||
log.debug('Removing %s from world.commands[%s]', cmdfunc, cmdname)
|
log.debug("Removing %s from world.services['pylink'].commands[%s]", cmdfunc, cmdname)
|
||||||
world.commands[cmdname].remove(cmdfunc)
|
world.services['pylink'].commands[cmdname].remove(cmdfunc)
|
||||||
|
|
||||||
# If the cmdfunc list is empty, remove it.
|
# If the cmdfunc list is empty, remove it.
|
||||||
if not cmdfuncs:
|
if not cmdfuncs:
|
||||||
log.debug("Removing world.commands[%s] (it's empty now)", cmdname)
|
log.debug("Removing world.services['pylink'].commands[%s] (it's empty now)", cmdname)
|
||||||
del world.commands[cmdname]
|
del world.services['pylink'].commands[cmdname]
|
||||||
|
|
||||||
# Remove any command hooks set by the plugin.
|
# Remove any command hooks set by the plugin.
|
||||||
for hookname, hookfuncs in world.hooks.copy().items():
|
for hookname, hookfuncs in world.hooks.copy().items():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user