mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 11:09:23 +01:00
Add --without option for Mist.last
This commit is contained in:
parent
2a040b475f
commit
07757282f2
@ -415,7 +415,7 @@ class Misc(callbacks.Privmsg):
|
|||||||
ircutils.isChannel(msg.args[0])
|
ircutils.isChannel(msg.args[0])
|
||||||
|
|
||||||
def last(self, irc, msg, args):
|
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
|
Returns the last message matching the given criteria. --from requires
|
||||||
a nick from whom the message came; --in and --to require a channel the
|
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=',
|
(optlist, rest) = getopt.getopt(args, '', ['from=', 'in=', 'to=',
|
||||||
'with=', 'regexp=',
|
'with=', 'regexp=',
|
||||||
'nolimit'])
|
'without=', 'nolimit'])
|
||||||
predicates = {}
|
predicates = {}
|
||||||
nolimit = False
|
nolimit = False
|
||||||
if ircutils.isChannel(msg.args[0]):
|
if ircutils.isChannel(msg.args[0]):
|
||||||
@ -444,6 +444,10 @@ class Misc(callbacks.Privmsg):
|
|||||||
def f(m, arg=arg):
|
def f(m, arg=arg):
|
||||||
return arg.lower() in m.args[1].lower()
|
return arg.lower() in m.args[1].lower()
|
||||||
predicates.setdefault('with', []).append(f)
|
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':
|
elif option == '--regexp':
|
||||||
try:
|
try:
|
||||||
r = utils.perlReToPythonRe(arg)
|
r = utils.perlReToPythonRe(arg)
|
||||||
|
@ -143,7 +143,8 @@ class MiscTestCase(ChannelPluginTestCase):
|
|||||||
self.assertResponse('last', '<%s> foo bar baz' % self.nick)
|
self.assertResponse('last', '<%s> foo bar baz' % self.nick)
|
||||||
self.assertRegexp('last', '<%s> @last' % self.nick)
|
self.assertRegexp('last', '<%s> @last' % self.nick)
|
||||||
self.assertResponse('last --with foo', '<%s> foo bar baz' % 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/',
|
self.assertResponse('last --regexp m/bar/',
|
||||||
'<%s> foo bar baz' % self.nick)
|
'<%s> foo bar baz' % self.nick)
|
||||||
self.assertResponse('last --from %s' % self.nick.upper(),
|
self.assertResponse('last --from %s' % self.nick.upper(),
|
||||||
|
Loading…
Reference in New Issue
Block a user