From 77ff4f8036b0954c2ec95c80747d324d98b04360 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Wed, 10 Sep 2003 22:29:34 +0000 Subject: [PATCH] Help updates, updates for metagoogle, and a change in bolding. --- plugins/Google.py | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/plugins/Google.py b/plugins/Google.py index 105b199c0..eafd203f0 100644 --- a/plugins/Google.py +++ b/plugins/Google.py @@ -128,7 +128,7 @@ class Google(callbacks.PrivmsgCommandAndRegexp): title = utils.htmlToText(result.title.encode('utf-8')) url = result.URL if title: - results.append('\x02%s\x02: <%s>' % (title, url)) + results.append('\x02%s\x0F: <%s>' % (title, url)) else: results.append(url) if not results: @@ -148,19 +148,20 @@ class Google(callbacks.PrivmsgCommandAndRegexp): googlelicensekey = privmsgs.checkCapability(googlelicensekey, 'admin') def google(self, irc, msg, args): - """ [--{language,restrict}=] [--{safe,similar}] + """ [--{language,restrict}=] [--{notsafe,similar}] Searches google.com for the given string. As many results as can fit are included. --language accepts a language abbreviation; --restrict restricts the results to certain classes of things; --similar tells - Google not to filter similar results. + Google not to filter similar results. --notsafe allows possibly + work-unsafe results. """ (optlist, rest) = getopt.getopt(args, '', ['language=', 'restrict=', - 'safe', 'similar']) + 'notsafe', 'similar']) kwargs = {'language': 'lang_en', 'safeSearch': 1} for (option, argument) in optlist: - if option == '--safe': - kwargs['safeSearch'] = True + if option == '--notsafe': + kwargs['safeSearch'] = False elif option == '--similar': kwargs['filter'] = False else: @@ -170,28 +171,31 @@ class Google(callbacks.PrivmsgCommandAndRegexp): irc.reply(msg, self.formatData(data)) def metagoogle(self, irc, msg, args): - """ [--(language,restrict,safe,filter)=] + """ [--(language,restrict)=] [--{similar,notsafe}] Searches google and gives all the interesting meta information about - the search. + the search. See the help for the google command for a detailed + description of the parameters. """ (optlist, rest) = getopt.getopt(args, '', ['language=', 'restrict=', - 'safe=', 'filter=']) + 'notsafe', 'similar']) kwargs = {'language': 'lang_en', 'safeSearch': 1} for option, argument in optlist: - kwargs[option[2:]] = argument + if option == '--notsafe': + kwargs['safeSearch'] = False + elif option == '--similar': + kwargs['filter'] = False + else: + kwargs[option[2:]] = argument searchString = privmsgs.getArgs(rest) data = search(searchString, **kwargs) meta = data.meta categories = [d['fullViewableName'] for d in meta.directoryCategories] - categories = [repr(s.replace('_', ' ')) for s in categories] - if len(categories) > 1: - categories = ', and '.join([', '.join(categories[:-1]), - categories[-1]]) - elif not categories: - categories = '' + categories = [utils.dqrepr(s.replace('_', ' ')) for s in categories] + if categories: + categories = utils.commaAndify(categories) else: - categories = categories[0] + categories = '' s = 'Search for %r returned %s %s results in %s seconds.%s' % \ (meta.searchQuery, meta.estimateIsExact and 'exactly' or 'approximately',