mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-22 02:32:42 +01:00
Add unaddressedRegexps to PluginRegexp.
This commit is contained in:
parent
53cc36bd9c
commit
44ef2bd81a
@ -1277,12 +1277,14 @@ class PluginRegexp(Plugin):
|
|||||||
flags = re.I
|
flags = re.I
|
||||||
regexps = ()
|
regexps = ()
|
||||||
addressedRegexps = ()
|
addressedRegexps = ()
|
||||||
|
unaddressedRegexps = ()
|
||||||
Proxy = SimpleProxy
|
Proxy = SimpleProxy
|
||||||
def __init__(self, irc):
|
def __init__(self, irc):
|
||||||
self.__parent = super(PluginRegexp, self)
|
self.__parent = super(PluginRegexp, self)
|
||||||
self.__parent.__init__(irc)
|
self.__parent.__init__(irc)
|
||||||
self.res = []
|
self.res = []
|
||||||
self.addressedRes = []
|
self.addressedRes = []
|
||||||
|
self.unaddressedRes = []
|
||||||
for name in self.regexps:
|
for name in self.regexps:
|
||||||
method = getattr(self, name)
|
method = getattr(self, name)
|
||||||
r = re.compile(method.__doc__, self.flags)
|
r = re.compile(method.__doc__, self.flags)
|
||||||
@ -1291,6 +1293,10 @@ class PluginRegexp(Plugin):
|
|||||||
method = getattr(self, name)
|
method = getattr(self, name)
|
||||||
r = re.compile(method.__doc__, self.flags)
|
r = re.compile(method.__doc__, self.flags)
|
||||||
self.addressedRes.append((r, name))
|
self.addressedRes.append((r, name))
|
||||||
|
for name in self.unaddressedRegexps:
|
||||||
|
method = getattr(self, name)
|
||||||
|
r = re.compile(method.__doc__, self.flags)
|
||||||
|
self.unaddressedRes.append((r, name))
|
||||||
|
|
||||||
def _callRegexp(self, name, irc, msg, m):
|
def _callRegexp(self, name, irc, msg, m):
|
||||||
method = getattr(self, name)
|
method = getattr(self, name)
|
||||||
@ -1311,6 +1317,10 @@ class PluginRegexp(Plugin):
|
|||||||
if msg.isError:
|
if msg.isError:
|
||||||
return
|
return
|
||||||
proxy = self.Proxy(irc, msg)
|
proxy = self.Proxy(irc, msg)
|
||||||
|
if not msg.addressed:
|
||||||
|
for (r, name) in self.unaddressedRes:
|
||||||
|
for m in r.finditer(msg.args[1]):
|
||||||
|
self._callRegexp(name, proxy, msg, m)
|
||||||
for (r, name) in self.res:
|
for (r, name) in self.res:
|
||||||
for m in r.finditer(msg.args[1]):
|
for m in r.finditer(msg.args[1]):
|
||||||
self._callRegexp(name, proxy, msg, m)
|
self._callRegexp(name, proxy, msg, m)
|
||||||
|
Loading…
Reference in New Issue
Block a user