From 470e1ff2459727d3990ced413b616b459ae962df Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Mon, 1 Mar 2010 20:51:22 +0100 Subject: Added missing part of IRCHandler. --- modules/quotes.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'modules') diff --git a/modules/quotes.py b/modules/quotes.py index 30a2c25..4f0816d 100644 --- a/modules/quotes.py +++ b/modules/quotes.py @@ -106,6 +106,52 @@ class IRCHandler(Quotes): def get(self, *args): 'Print a quote.' if not len(args): + yield 'Quote: Missing quote number.' + return + args = args[0] + if args[0] == '#': + args = args[1:] + if not args.isdigit(): + yield 'Quote: Identifier must be a number.' + return + qid = int(args) + qid, q = Quotes.get(self, qid) + if not q: + yield 'Quote: That quote does not exist.' + else: + for l in self.output(((qid, q),)): + yield l + + def help(self, *args): + 'Show this help.' + funcs = ('random', 'get id', 'info id', 'find text', 'afind text', 'efind text', 'rfind regexp', 'add text', 'stats', 'help') + l = [] + maxlen = 0 + for i in funcs: + name = i.split(' ') + if len(name) == 2: + name, arg = name + else: + name, arg = name[0], None + l.append(('%s <%s>' % (name, arg) if arg else name, getattr(self, name).__doc__)) + if len(l[-1][0]) > maxlen: + maxlen = len(l[-1][0]) + return ('%s%s%s' % (x[0], ' ' * (maxlen - len(x[0]) + 1), x[1]) for x in l) + + def info(self, *args): + 'Print stored information about a quote.' + if not len(args): + yield 'Quote: Missing quote number.' + return + elif not args[0].isdigit(): + yield 'Quote: Identifier must by a number.' + return + n = int(args[0]) + info = Quotes.info(self, n) + if not info: + yield 'Quote: That quote does not exist.' + else: + yield '\002Quote #%d\002 was added by %s at %s.' % (n, str(info[1]) if info[1] else '(unknown nick)', self.format_date(info[2]) if info[2] else '(unknown date)') quote_handler = IRCHandler() -- cgit v1.2.3