From 97c18a24598407287aba364170383870a02380f0 Mon Sep 17 00:00:00 2001 From: "Brian S. Stephan" Date: Sun, 17 Jan 2016 09:49:55 -0600 Subject: [PATCH] ircbot: provide feedback option to _plugin_unload --- dr_botzo/ircbot/bot.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/dr_botzo/ircbot/bot.py b/dr_botzo/ircbot/bot.py index d5f0e26..9cec53a 100644 --- a/dr_botzo/ircbot/bot.py +++ b/dr_botzo/ircbot/bot.py @@ -686,7 +686,7 @@ class IRCBot(irc.client.SimpleIRCClient): log.debug("calling _unload_plugin on %s", 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. 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 :param plugin_path: path (likely a relative one) of the plugin to attempt to unload :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) @@ -718,9 +720,10 @@ class IRCBot(irc.client.SimpleIRCClient): del plugin 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)) # loop over the sys.modules entries, for debugging