mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Removed --fancy option; made True the default.
This commit is contained in:
parent
d1e049cb04
commit
bb231a19e5
16
src/Misc.py
16
src/Misc.py
@ -274,7 +274,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,fancy}] <args>
|
"""[--{from,in,to,with,regexp}] <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
|
||||||
@ -283,15 +283,12 @@ class Misc(callbacks.Privmsg):
|
|||||||
--fancy determines whether or not to show the nick; the default is not
|
--fancy determines whether or not to show the nick; the default is not
|
||||||
"""
|
"""
|
||||||
(optlist, rest) = getopt.getopt(args, '', ['from=', 'in=', 'to=',
|
(optlist, rest) = getopt.getopt(args, '', ['from=', 'in=', 'to=',
|
||||||
'with=', 'regexp=',
|
'with=', 'regexp='])
|
||||||
'fancy'])
|
|
||||||
fancy = False
|
|
||||||
predicates = []
|
predicates = []
|
||||||
for (option, arg) in optlist:
|
for (option, arg) in optlist:
|
||||||
option = option.strip('-')
|
option = option.strip('-')
|
||||||
if option == 'fancy':
|
if option == 'from':
|
||||||
fancy = True
|
|
||||||
elif option == 'from':
|
|
||||||
predicates.append(lambda m, arg=arg: \
|
predicates.append(lambda m, arg=arg: \
|
||||||
ircutils.hostmaskPatternEqual(arg, m.nick))
|
ircutils.hostmaskPatternEqual(arg, m.nick))
|
||||||
elif option == 'in' or option == 'to':
|
elif option == 'in' or option == 'to':
|
||||||
@ -317,10 +314,7 @@ class Misc(callbacks.Privmsg):
|
|||||||
if not predicate(m):
|
if not predicate(m):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
if fancy:
|
irc.reply(msg, ircmsgs.prettyPrint(m))
|
||||||
irc.reply(msg, ircmsgs.prettyPrint(m))
|
|
||||||
else:
|
|
||||||
irc.reply(msg, m.args[1])
|
|
||||||
return
|
return
|
||||||
irc.error(msg, 'I couldn\'t find a message matching that criteria.')
|
irc.error(msg, 'I couldn\'t find a message matching that criteria.')
|
||||||
|
|
||||||
|
@ -116,15 +116,17 @@ class MiscTestCase(ChannelPluginTestCase, PluginDocumentation):
|
|||||||
|
|
||||||
def testLast(self):
|
def testLast(self):
|
||||||
self.feedMsg('foo bar baz')
|
self.feedMsg('foo bar baz')
|
||||||
self.assertResponse('last', 'foo bar baz')
|
self.assertResponse('last', '<%s> foo bar baz' % self.nick)
|
||||||
self.assertRegexp('last', 'last')
|
self.assertRegexp('last', '<%s> @last' % self.nick)
|
||||||
self.assertResponse('last --with foo', 'foo bar baz')
|
self.assertResponse('last --with foo', '<%s> foo bar baz' % self.nick)
|
||||||
self.assertRegexp('last --regexp m/\s+/', 'last --with foo')
|
self.assertRegexp('last --regexp m/\s+/', 'last --with foo')
|
||||||
self.assertResponse('last --regexp m/bar/', 'foo bar baz')
|
self.assertResponse('last --regexp m/bar/',
|
||||||
|
'<%s> foo bar baz' % self.nick)
|
||||||
self.assertResponse('last --from %s' % self.nick.upper(),
|
self.assertResponse('last --from %s' % self.nick.upper(),
|
||||||
'@last --regexp m/bar/')
|
'<%s> @last --regexp m/bar/' % self.nick)
|
||||||
self.assertResponse('last --from %s*' % self.nick[0],
|
self.assertResponse('last --from %s*' % self.nick[0],
|
||||||
'@last --from %s' % self.nick.upper())
|
'<%s> @last --from %s' %
|
||||||
|
(self.nick, self.nick.upper()))
|
||||||
|
|
||||||
def testMore(self):
|
def testMore(self):
|
||||||
self.assertRegexp('echo %s' % ('abc'*300), 'more')
|
self.assertRegexp('echo %s' % ('abc'*300), 'more')
|
||||||
|
Loading…
Reference in New Issue
Block a user