From b2efbdc84ca9922ee000c5834e2df8d6f756eb33 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Sat, 7 Feb 2004 11:48:03 +0000 Subject: [PATCH] Added RFE #871658. --- src/Owner.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/Owner.py b/src/Owner.py index 6d0e19e2b..c7fcf3cdb 100644 --- a/src/Owner.py +++ b/src/Owner.py @@ -122,6 +122,30 @@ conf.registerGlobalValue(conf.supybot.commands.defaultPlugins, conf.registerGlobalValue(conf.supybot.commands.defaultPlugins, 'ignore', registry.String('Admin', '')) + +class holder(object): + pass + +class LogProxy(object): + """ + + Logs to the global supybot log at critical priority. Useful for + marking logfiles for later searching. + """ + def __init__(self, log): + self.log = log + self.im_func = holder() + self.im_func.func_name = 'log' + + def __call__(self, irc, msg, args): + text = privmsgs.getArgs(args) + log.critical(text) + irc.replySuccess() + + def __getattr__(self, attr): + return getattr(self.log, attr) + + class Owner(privmsgs.CapabilityCheckingPrivmsg): # This plugin must be first; its priority must be lowest; otherwise odd # things will happen when adding callbacks. @@ -130,6 +154,7 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg): _srcPlugins = ('Admin', 'Channel', 'Config', 'Misc', 'Owner', 'User') def __init__(self): callbacks.Privmsg.__init__(self) + self.log = LogProxy(self.log) setattr(self.__class__, 'exec', self.__class__._exec) for (name, s) in registry._cache.iteritems(): if name.startswith('supybot.plugins'): @@ -139,6 +164,10 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg): continue conf.registerPlugin(name) + def isCommand(self, methodName): + return methodName == 'log' or \ + privmsgs.CapabilityCheckingPrivmsg.isCommand(self, methodName) + def do001(self, irc, msg): self.log.info('Loading other src/ plugins.') for s in ('Admin', 'Channel', 'Config', 'Misc', 'User'):