From 0769c0a586602c18f7935d421b779d941701a2a6 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Tue, 21 Oct 2003 22:24:13 +0000 Subject: [PATCH] Added special handling to make sure reloading Misc doesn't kill MoobotFactoids. --- src/Misc.py | 9 ++++++++- src/Owner.py | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Misc.py b/src/Misc.py index 0127d6d23..8a7fbd6cc 100755 --- a/src/Misc.py +++ b/src/Misc.py @@ -63,7 +63,14 @@ def replyWhenNotCommand(irc, msg, notCommands): s = '%s are not commands' % \ utils.commaAndify(notCommands) irc.reply(msg, s) - + +def reload(x=None): + """Called when this plugin is reloaded.""" + global replyWhenNotCommand + if x is None: + return replyWhenNotCommand + else: + replyWhenNotCommand = x class Misc(callbacks.Privmsg): def doPrivmsg(self, irc, msg): diff --git a/src/Owner.py b/src/Owner.py index 09cd73ebd..020e5c434 100644 --- a/src/Owner.py +++ b/src/Owner.py @@ -321,8 +321,13 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg): name = privmsgs.getArgs(args) callbacks = irc.removeCallback(name) if callbacks: + module = sys.modules[callbacks[0].__module__] + if hasattr(module, 'reload'): + x = module.reload() try: module = loadPluginModule(name) + if hasattr(module, 'reload'): + module.reload(x) for callback in callbacks: callback.die() del callback