Owner: fix 'unload' writing duplicate entries to supybot.plugins

Fetch the existing plugin callback to determine the plugin's name in the right case.

Closes #1295.
This commit is contained in:
James Lu 2017-10-27 23:34:08 -07:00
parent 2ba7bc5c16
commit ec2cf4af37

View File

@ -499,16 +499,21 @@ class Owner(callbacks.Plugin):
return return
# Let's do this so even if the plugin isn't currently loaded, it doesn't # Let's do this so even if the plugin isn't currently loaded, it doesn't
# stay attempting to load. # stay attempting to load.
conf.registerPlugin(name, False) old_callback = irc.getCallback(name)
callbacks = irc.removeCallback(name) if old_callback:
if callbacks: # Normalize the plugin case to prevent duplicate registration
for callback in callbacks: # entries, https://github.com/ProgVal/Limnoria/issues/1295
callback.die() name = old_callback.name()
del callback conf.registerPlugin(name, False)
gc.collect() callbacks = irc.removeCallback(name)
irc.replySuccess() if callbacks:
else: for callback in callbacks:
irc.error('There was no plugin %s.' % name) callback.die()
del callback
gc.collect()
irc.replySuccess()
return
irc.error('There was no plugin %s.' % name)
unload = wrap(unload, ['something']) unload = wrap(unload, ['something'])
def defaultcapability(self, irc, msg, args, action, capability): def defaultcapability(self, irc, msg, args, action, capability):