diff --git a/src/Misc.py b/src/Misc.py index a77b4b58c..00ed11d9d 100755 --- a/src/Misc.py +++ b/src/Misc.py @@ -415,7 +415,7 @@ class Misc(callbacks.Privmsg): ircutils.isChannel(msg.args[0]) def last(self, irc, msg, args): - """[--{from,in,to,with,regexp,nolimit}] + """[--{from,in,to,with,without,regexp,nolimit}] Returns the last message matching the given criteria. --from requires a nick from whom the message came; --in and --to require a channel the @@ -426,7 +426,7 @@ class Misc(callbacks.Privmsg): """ (optlist, rest) = getopt.getopt(args, '', ['from=', 'in=', 'to=', 'with=', 'regexp=', - 'nolimit']) + 'without=', 'nolimit']) predicates = {} nolimit = False if ircutils.isChannel(msg.args[0]): @@ -444,6 +444,10 @@ class Misc(callbacks.Privmsg): def f(m, arg=arg): return arg.lower() in m.args[1].lower() predicates.setdefault('with', []).append(f) + elif option == '--without': + def f(m, arg=arg): + return arg.lower() not in m.args[1].lower() + predicates.setdefault('without', []).append(f) elif option == '--regexp': try: r = utils.perlReToPythonRe(arg) diff --git a/test/test_Misc.py b/test/test_Misc.py index d1035bdbe..34f5d0e87 100644 --- a/test/test_Misc.py +++ b/test/test_Misc.py @@ -143,7 +143,8 @@ class MiscTestCase(ChannelPluginTestCase): self.assertResponse('last', '<%s> foo bar baz' % self.nick) self.assertRegexp('last', '<%s> @last' % self.nick) self.assertResponse('last --with foo', '<%s> foo bar baz' % self.nick) - self.assertRegexp('last --regexp m/\s+/', 'last --with foo') + self.assertResponse('last --without foo', '<%s> @last' % self.nick) + self.assertRegexp('last --regexp m/\s+/', 'last --without foo') self.assertResponse('last --regexp m/bar/', '<%s> foo bar baz' % self.nick) self.assertResponse('last --from %s' % self.nick.upper(),