mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 19:19:32 +01:00
Added googlefight command and cleaned up the output of metagoogle command.
This commit is contained in:
parent
f7637bd19c
commit
1230769fe0
@ -145,6 +145,7 @@ class GooglePrivmsg(callbacks.Privmsg):
|
|||||||
data = google.doGoogleSearch(searchString, **kwargs)
|
data = google.doGoogleSearch(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]
|
||||||
if len(categories) > 1:
|
if len(categories) > 1:
|
||||||
categories = ', and '.join([', '.join(categories[:-1]),
|
categories = ', and '.join([', '.join(categories[:-1]),
|
||||||
categories[-1]])
|
categories[-1]])
|
||||||
@ -160,6 +161,22 @@ class GooglePrivmsg(callbacks.Privmsg):
|
|||||||
categories and ' Categories include %s.' % categories)
|
categories and ' Categories include %s.' % categories)
|
||||||
irc.reply(msg, s)
|
irc.reply(msg, s)
|
||||||
|
|
||||||
|
def googlefight(self, irc, msg, args):
|
||||||
|
"""<search string> <search string> [<search string> ...]
|
||||||
|
|
||||||
|
Returns the results of each search, in order, from greatest number
|
||||||
|
of results to least.
|
||||||
|
"""
|
||||||
|
|
||||||
|
results = []
|
||||||
|
for arg in args:
|
||||||
|
data = google.doGoogleSearch(arg)
|
||||||
|
results.append((data.meta.estimatedTotalResultsCount, arg))
|
||||||
|
results.sort()
|
||||||
|
results.reverse()
|
||||||
|
s = ', '.join(['%r: %s' % (s, i) for (i, s) in results])
|
||||||
|
irc.reply(msg, s)
|
||||||
|
|
||||||
def googlesite(self, irc, msg, args):
|
def googlesite(self, irc, msg, args):
|
||||||
"""<site> <search string>
|
"""<site> <search string>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user