diff --git a/src/Misc.py b/src/Misc.py index cc3d3fb79..cc0398063 100755 --- a/src/Misc.py +++ b/src/Misc.py @@ -274,7 +274,7 @@ class Misc(callbacks.Privmsg): ircutils.isChannel(msg.args[0]) def last(self, irc, msg, args): - """[--{from,in,to,with,regexp,fancy}] + """[--{from,in,to,with,regexp}] Returns the last message matching the given criteria. --from requires 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 """ (optlist, rest) = getopt.getopt(args, '', ['from=', 'in=', 'to=', - 'with=', 'regexp=', - 'fancy']) - fancy = False + 'with=', 'regexp=']) + predicates = [] for (option, arg) in optlist: option = option.strip('-') - if option == 'fancy': - fancy = True - elif option == 'from': + if option == 'from': predicates.append(lambda m, arg=arg: \ ircutils.hostmaskPatternEqual(arg, m.nick)) elif option == 'in' or option == 'to': @@ -317,10 +314,7 @@ class Misc(callbacks.Privmsg): if not predicate(m): break else: - if fancy: - irc.reply(msg, ircmsgs.prettyPrint(m)) - else: - irc.reply(msg, m.args[1]) + irc.reply(msg, ircmsgs.prettyPrint(m)) return irc.error(msg, 'I couldn\'t find a message matching that criteria.') diff --git a/test/test_Misc.py b/test/test_Misc.py index 767291e50..2cf9ffb35 100644 --- a/test/test_Misc.py +++ b/test/test_Misc.py @@ -116,15 +116,17 @@ class MiscTestCase(ChannelPluginTestCase, PluginDocumentation): def testLast(self): self.feedMsg('foo bar baz') - self.assertResponse('last', 'foo bar baz') - self.assertRegexp('last', 'last') - self.assertResponse('last --with foo', 'foo bar baz') + 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 --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(), - '@last --regexp m/bar/') + '<%s> @last --regexp m/bar/' % self.nick) 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): self.assertRegexp('echo %s' % ('abc'*300), 'more')