Misc.last --nolimit

This commit is contained in:
James Vega 2004-06-28 19:09:25 +00:00
parent d9d8c04e24
commit 30a8c060ad
2 changed files with 19 additions and 6 deletions

View File

@ -1,3 +1,6 @@
* Added --nolimit option to Misc.last, which causes it to return all
matches that are in the history.
* Added conf.supybot.plugins.Herald.defaultHerald, which provides * Added conf.supybot.plugins.Herald.defaultHerald, which provides
a default herald to use for unregistered users. Herald.default was a default herald to use for unregistered users. Herald.default was
also added as a friendly interface to managing the defaultHerald. also added as a friendly interface to managing the defaultHerald.

View File

@ -406,9 +406,10 @@ class Misc(callbacks.Privmsg):
match. By default, the current channel is searched. match. By default, the current channel is searched.
""" """
(optlist, rest) = getopt.getopt(args, '', ['from=', 'in=', 'to=', (optlist, rest) = getopt.getopt(args, '', ['from=', 'in=', 'to=',
'with=', 'regexp=']) 'with=', 'regexp=',
'nolimit'])
predicates = {} predicates = {}
nolimit = False
if ircutils.isChannel(msg.args[0]): if ircutils.isChannel(msg.args[0]):
predicates['in'] = lambda m: m.args[0] == msg.args[0] predicates['in'] = lambda m: m.args[0] == msg.args[0]
for (option, arg) in optlist: for (option, arg) in optlist:
@ -436,18 +437,27 @@ class Misc(callbacks.Privmsg):
except ValueError, e: except ValueError, e:
irc.error(str(e)) irc.error(str(e))
return return
elif option == '--nolimit':
nolimit = True
iterable = ifilter(self._validLastMsg, reversed(irc.state.history)) iterable = ifilter(self._validLastMsg, reversed(irc.state.history))
iterable.next() # Drop the first message. iterable.next() # Drop the first message.
predicates = list(utils.flatten(predicates.itervalues())) predicates = list(utils.flatten(predicates.itervalues()))
resp = []
for m in iterable: for m in iterable:
for predicate in predicates: for predicate in predicates:
if not predicate(m): if not predicate(m):
break break
else: else:
irc.reply(ircmsgs.prettyPrint(m)) if nolimit:
return resp.append(ircmsgs.prettyPrint(m))
irc.error('I couldn\'t find a message matching that criteria in ' else:
'my history of %s messages.' % len(irc.state.history)) irc.reply(ircmsgs.prettyPrint(m))
return
if not resp:
irc.error('I couldn\'t find a message matching that criteria in '
'my history of %s messages.' % len(irc.state.history))
else:
irc.reply(utils.commaAndify(resp))
def seconds(self, irc, msg, args): def seconds(self, irc, msg, args):
"""[<years>y] [<weeks>w] [<days>d] [<hours>h] [<minutes>m] [<seconds>s] """[<years>y] [<weeks>w] [<days>d] [<hours>h] [<minutes>m] [<seconds>s]