Add --without option for Mist.last

This commit is contained in:
James Vega 2004-08-24 20:22:12 +00:00
parent 2a040b475f
commit 07757282f2
2 changed files with 8 additions and 3 deletions

View File

@ -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}] <args>
"""[--{from,in,to,with,without,regexp,nolimit}] <args>
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)

View File

@ -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(),