mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 19:19:32 +01:00
Help updates, updates for metagoogle, and a change in bolding.
This commit is contained in:
parent
7605f6512e
commit
77ff4f8036
@ -128,7 +128,7 @@ class Google(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
title = utils.htmlToText(result.title.encode('utf-8'))
|
title = utils.htmlToText(result.title.encode('utf-8'))
|
||||||
url = result.URL
|
url = result.URL
|
||||||
if title:
|
if title:
|
||||||
results.append('\x02%s\x02: <%s>' % (title, url))
|
results.append('\x02%s\x0F: <%s>' % (title, url))
|
||||||
else:
|
else:
|
||||||
results.append(url)
|
results.append(url)
|
||||||
if not results:
|
if not results:
|
||||||
@ -148,19 +148,20 @@ class Google(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
googlelicensekey = privmsgs.checkCapability(googlelicensekey, 'admin')
|
googlelicensekey = privmsgs.checkCapability(googlelicensekey, 'admin')
|
||||||
|
|
||||||
def google(self, irc, msg, args):
|
def google(self, irc, msg, args):
|
||||||
"""<search string> [--{language,restrict}=<value>] [--{safe,similar}]
|
"""<search> [--{language,restrict}=<value>] [--{notsafe,similar}]
|
||||||
|
|
||||||
Searches google.com for the given string. As many results as can fit
|
Searches google.com for the given string. As many results as can fit
|
||||||
are included. --language accepts a language abbreviation; --restrict
|
are included. --language accepts a language abbreviation; --restrict
|
||||||
restricts the results to certain classes of things; --similar tells
|
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=',
|
(optlist, rest) = getopt.getopt(args, '', ['language=', 'restrict=',
|
||||||
'safe', 'similar'])
|
'notsafe', 'similar'])
|
||||||
kwargs = {'language': 'lang_en', 'safeSearch': 1}
|
kwargs = {'language': 'lang_en', 'safeSearch': 1}
|
||||||
for (option, argument) in optlist:
|
for (option, argument) in optlist:
|
||||||
if option == '--safe':
|
if option == '--notsafe':
|
||||||
kwargs['safeSearch'] = True
|
kwargs['safeSearch'] = False
|
||||||
elif option == '--similar':
|
elif option == '--similar':
|
||||||
kwargs['filter'] = False
|
kwargs['filter'] = False
|
||||||
else:
|
else:
|
||||||
@ -170,28 +171,31 @@ class Google(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
irc.reply(msg, self.formatData(data))
|
irc.reply(msg, self.formatData(data))
|
||||||
|
|
||||||
def metagoogle(self, irc, msg, args):
|
def metagoogle(self, irc, msg, args):
|
||||||
"""<search string> [--(language,restrict,safe,filter)=<value>]
|
"""<search> [--(language,restrict)=<value>] [--{similar,notsafe}]
|
||||||
|
|
||||||
Searches google and gives all the interesting meta information about
|
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=',
|
(optlist, rest) = getopt.getopt(args, '', ['language=', 'restrict=',
|
||||||
'safe=', 'filter='])
|
'notsafe', 'similar'])
|
||||||
kwargs = {'language': 'lang_en', 'safeSearch': 1}
|
kwargs = {'language': 'lang_en', 'safeSearch': 1}
|
||||||
for option, argument in optlist:
|
for option, argument in optlist:
|
||||||
|
if option == '--notsafe':
|
||||||
|
kwargs['safeSearch'] = False
|
||||||
|
elif option == '--similar':
|
||||||
|
kwargs['filter'] = False
|
||||||
|
else:
|
||||||
kwargs[option[2:]] = argument
|
kwargs[option[2:]] = argument
|
||||||
searchString = privmsgs.getArgs(rest)
|
searchString = privmsgs.getArgs(rest)
|
||||||
data = search(searchString, **kwargs)
|
data = search(searchString, **kwargs)
|
||||||
meta = data.meta
|
meta = data.meta
|
||||||
categories = [d['fullViewableName'] for d in meta.directoryCategories]
|
categories = [d['fullViewableName'] for d in meta.directoryCategories]
|
||||||
categories = [repr(s.replace('_', ' ')) for s in categories]
|
categories = [utils.dqrepr(s.replace('_', ' ')) for s in categories]
|
||||||
if len(categories) > 1:
|
if categories:
|
||||||
categories = ', and '.join([', '.join(categories[:-1]),
|
categories = utils.commaAndify(categories)
|
||||||
categories[-1]])
|
|
||||||
elif not categories:
|
|
||||||
categories = ''
|
|
||||||
else:
|
else:
|
||||||
categories = categories[0]
|
categories = ''
|
||||||
s = 'Search for %r returned %s %s results in %s seconds.%s' % \
|
s = 'Search for %r returned %s %s results in %s seconds.%s' % \
|
||||||
(meta.searchQuery,
|
(meta.searchQuery,
|
||||||
meta.estimateIsExact and 'exactly' or 'approximately',
|
meta.estimateIsExact and 'exactly' or 'approximately',
|
||||||
|
Loading…
Reference in New Issue
Block a user