Added googlefight command and cleaned up the output of metagoogle command.

This commit is contained in:
Jeremy Fincher 2003-07-30 19:39:58 +00:00
parent f7637bd19c
commit 1230769fe0

View File

@ -145,6 +145,7 @@ class GooglePrivmsg(callbacks.Privmsg):
data = google.doGoogleSearch(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]])
@ -160,6 +161,22 @@ class GooglePrivmsg(callbacks.Privmsg):
categories and ' Categories include %s.' % categories)
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):
"""<site> <search string>