SedRegex: implement 's' regex flag to only match the caller's message

From: 87c79db3d0
This commit is contained in:
James Lu 2016-12-17 20:48:04 -08:00
parent bd0b1158fc
commit 24ae250ac4

View File

@ -118,18 +118,23 @@ class SedRegex(callbacks.PluginRegexp):
return return
next(iterable) next(iterable)
for m in iterable: if 's' in flags: # Special 's' flag lets the bot only look at self messages
if m.command in ('PRIVMSG', 'NOTICE') and \ target = msg.nick
m.args[0] == msg.args[0] and m.tagged('receivedBy') == irc: else:
target = regex.group('nick') target = regex.group('nick')
if not ircutils.isNick(str(target), strictRfc=True): if not ircutils.isNick(str(target), strictRfc=True):
return return
for m in iterable:
if m.command in ('PRIVMSG', 'NOTICE') and \
m.args[0] == msg.args[0] and m.tagged('receivedBy') == irc:
if target and m.nick != target: if target and m.nick != target:
continue continue
# Don't snarf ignored users' messages unless specifically # Don't snarf ignored users' messages unless specifically
# told to. # told to.
if ircdb.checkIgnored(m.prefix) and not target: if ircdb.checkIgnored(m.prefix) and not target:
continue continue
# When running substitutions, ignore the "* nick" part of any actions. # When running substitutions, ignore the "* nick" part of any actions.
action = ircmsgs.isAction(m) action = ircmsgs.isAction(m)
if action: if action: