Skip to content

Commit 850b4c3

Browse files
committed
MessageParser: Log and skip current regexp on error
1 parent 91accc0 commit 850b4c3

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

plugins/MessageParser/plugin.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -192,20 +192,23 @@ def do_privmsg_notice(self, irc, msg):
192192
return
193193
max_triggers = self.registryValue('maxTriggers', channel, irc.network)
194194
for (channel, regexp, action) in results:
195-
for match in re.finditer(regexp, msg.args[1]):
196-
if match is not None:
197-
thisaction = action
198-
self._updateRank(irc.network, channel, regexp)
199-
for (i, j) in enumerate(match.groups()):
200-
if match.group(i+1) is not None:
201-
# Need a lambda to prevent re.sub from
202-
# interpreting backslashes in the replacement
203-
thisaction = re.sub(r'\$' + str(i+1), lambda _: match.group(i+1), thisaction)
204-
actions.append((regexp, thisaction))
205-
if max_triggers != 0 and max_triggers == len(actions):
206-
break
207-
if max_triggers != 0 and max_triggers == len(actions):
208-
break
195+
try:
196+
for match in re.finditer(regexp, msg.args[1]):
197+
if match is not None:
198+
thisaction = action
199+
self._updateRank(irc.network, channel, regexp)
200+
for (i, j) in enumerate(match.groups()):
201+
if match.group(i+1) is not None:
202+
# Need a lambda to prevent re.sub from
203+
# interpreting backslashes in the replacement
204+
thisaction = re.sub(r'\$' + str(i+1), lambda _: match.group(i+1), thisaction)
205+
actions.append((regexp, thisaction))
206+
if max_triggers != 0 and max_triggers == len(actions):
207+
break
208+
if max_triggers != 0 and max_triggers == len(actions):
209+
break
210+
except Exception:
211+
self.log.exception('Error while handling %r', regexp)
209212

210213

211214
for (regexp, action) in actions:

0 commit comments

Comments
 (0)