ircbot: provide feedback option to _plugin_unload
This commit is contained in:
parent
10071f9094
commit
97c18a2459
|
@ -686,7 +686,7 @@ class IRCBot(irc.client.SimpleIRCClient):
|
||||||
log.debug("calling _unload_plugin on %s", plugin_path)
|
log.debug("calling _unload_plugin on %s", plugin_path)
|
||||||
self._unload_plugin(connection, event, plugin_path)
|
self._unload_plugin(connection, event, plugin_path)
|
||||||
|
|
||||||
def _unload_plugin(self, connection, event, plugin_path):
|
def _unload_plugin(self, connection, event, plugin_path, feedback=True):
|
||||||
"""Attempt to unload and del a module if it's loaded.
|
"""Attempt to unload and del a module if it's loaded.
|
||||||
|
|
||||||
This stops the plugin, which should (if it's coded properly) disconnect its
|
This stops the plugin, which should (if it's coded properly) disconnect its
|
||||||
|
@ -698,6 +698,8 @@ class IRCBot(irc.client.SimpleIRCClient):
|
||||||
:type event: Event
|
:type event: Event
|
||||||
:param plugin_path: path (likely a relative one) of the plugin to attempt to unload
|
:param plugin_path: path (likely a relative one) of the plugin to attempt to unload
|
||||||
:type plugin_path: str
|
:type plugin_path: str
|
||||||
|
:param feedback: whether or not to send messages to IRC regarding the unload attempt
|
||||||
|
:type feedback: bool
|
||||||
"""
|
"""
|
||||||
|
|
||||||
log.debug("trying to unload plugin %s", plugin_path)
|
log.debug("trying to unload plugin %s", plugin_path)
|
||||||
|
@ -718,9 +720,10 @@ class IRCBot(irc.client.SimpleIRCClient):
|
||||||
del plugin
|
del plugin
|
||||||
del sys.modules[plugin_path]
|
del sys.modules[plugin_path]
|
||||||
|
|
||||||
self.privmsg(dest, "Plugin '{0:s}' unloaded.".format(plugin_path))
|
if feedback:
|
||||||
|
self.privmsg(dest, "Plugin '{0:s}' unloaded.".format(plugin_path))
|
||||||
|
|
||||||
if not unloaded:
|
if not unloaded and feedback:
|
||||||
self.privmsg(dest, "Plugin '{0:s}' is not loaded.".format(plugin_path))
|
self.privmsg(dest, "Plugin '{0:s}' is not loaded.".format(plugin_path))
|
||||||
|
|
||||||
# loop over the sys.modules entries, for debugging
|
# loop over the sys.modules entries, for debugging
|
||||||
|
|
Loading…
Reference in New Issue