This commit is contained in:
Jeremy Fincher 2003-11-22 02:10:51 +00:00
parent 0e8891871f
commit 37c6516693

View File

@ -529,9 +529,9 @@ class Privmsg(irclib.IrcCallback):
"""Base class for all Privmsg handlers.""" """Base class for all Privmsg handlers."""
threaded = False threaded = False
public = True public = True
handled = False
alwaysCall = () alwaysCall = ()
noIgnore = False noIgnore = False
handled = False
commandArgs = ['self', 'irc', 'msg', 'args'] commandArgs = ['self', 'irc', 'msg', 'args']
_mores = {} # This must be class-scope, so all subclasses use the same one. _mores = {} # This must be class-scope, so all subclasses use the same one.
def __init__(self): def __init__(self):
@ -617,7 +617,6 @@ class Privmsg(irclib.IrcCallback):
def callCommand(self, f, irc, msg, *L): def callCommand(self, f, irc, msg, *L):
# Exceptions aren't caught here because IrcObjectProxy.finalEval # Exceptions aren't caught here because IrcObjectProxy.finalEval
# catches them and does The Right Thing. # catches them and does The Right Thing.
Privmsg.handled = True
start = time.time() start = time.time()
f(irc, msg, *L) f(irc, msg, *L)
elapsed = time.time() - start elapsed = time.time() - start
@ -739,24 +738,26 @@ class PrivmsgCommandAndRegexp(Privmsg):
raise raise
def doPrivmsg(self, irc, msg): def doPrivmsg(self, irc, msg):
handled = False
for (r, method) in self.res: for (r, method) in self.res:
originalHandled = self.handled
name = method.__name__ name = method.__name__
if handled and name not in self.alwaysCall:
continue
for m in r.finditer(msg.args[1]): for m in r.finditer(msg.args[1]):
if originalHandled and name not in self.alwaysCall:
continue
proxy = IrcObjectProxyRegexp(irc) proxy = IrcObjectProxyRegexp(irc)
self.callCommand(method, proxy, msg, m, catchErrors=True) self.callCommand(method, proxy, msg, m, catchErrors=True)
s = addressed(irc.nick, msg) handled = True
if s: if not Privmsg.handled:
for (r, method) in self.addressedRes: s = addressed(irc.nick, msg)
originalHandled = self.handled if s:
name = method.__name__ for (r, method) in self.addressedRes:
for m in r.finditer(s): name = method.__name__
if originalHandled and name not in self.alwaysCall: if handled and name not in self.alwaysCall:
continue continue
proxy = IrcObjectProxyRegexp(irc) for m in r.finditer(s):
self.callCommand(method,proxy,msg,m,catchErrors=True) proxy = IrcObjectProxyRegexp(irc)
self.callCommand(method,proxy,msg,m,catchErrors=True)
handled = True
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: