process multiple matches of a regexp per message

This commit is contained in:
Daniel Folkinshteyn 2010-03-17 12:37:34 -04:00
parent 95aa56c694
commit 6ceeace44d

View File

@ -134,15 +134,14 @@ class MessageParser(callbacks.Plugin, plugins.ChannelDBHandler):
if len(results) == 0: if len(results) == 0:
return return
for (regexp, action) in results: for (regexp, action) in results:
match = re.search(regexp, msg.args[1]) for match in re.finditer(regexp, msg.args[1]):
if match is not None: if match is not None:
self._updateRank(channel, regexp) thisaction = action
for (i, j) in enumerate(match.groups()): self._updateRank(channel, regexp)
action = re.sub(r'\$' + str(i+1), match.group(i+1), action) for (i, j) in enumerate(match.groups()):
actions.append(action) thisaction = re.sub(r'\$' + str(i+1), match.group(i+1), thisaction)
actions.append(thisaction)
#if len(actions) > 0:
# irc.replies(actions, prefixNick=False)
for action in actions: for action in actions:
self._runCommandFunction(irc, msg, action) self._runCommandFunction(irc, msg, action)