mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-09 12:29:22 +01:00
Changed formatting in presence of lacking titles and made it respond with as many results as it can.
This commit is contained in:
parent
9941d3534c
commit
cd73dfbc52
@ -44,6 +44,7 @@ Commands include:
|
|||||||
from baseplugin import *
|
from baseplugin import *
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
import operator
|
||||||
|
|
||||||
import google
|
import google
|
||||||
|
|
||||||
@ -81,14 +82,20 @@ class Google(callbacks.Privmsg):
|
|||||||
def formatData(self, data):
|
def formatData(self, data):
|
||||||
self._searched(data)
|
self._searched(data)
|
||||||
time = '(search took %s seconds)' % data.meta.searchTime
|
time = '(search took %s seconds)' % data.meta.searchTime
|
||||||
results = data.results[:3]
|
results = []
|
||||||
results = ['\x02%s\x02: %s' % \
|
for result in data.results:
|
||||||
(utils.htmlToText(r.title.encode('utf-8')), r.URL) \
|
title = utils.htmlToText(result.title.encode('utf-8'))
|
||||||
for r in results]
|
url = result.URL
|
||||||
|
if title:
|
||||||
|
results.append('\x02%s\x02: %s' % (title, url))
|
||||||
|
else:
|
||||||
|
results.append(url)
|
||||||
|
while reduce(operator.add, map((4).__add__,map(len, results)),0) > 400:
|
||||||
|
results.pop()
|
||||||
if not results:
|
if not results:
|
||||||
return 'No matches found %s' % time
|
return 'No matches found %s' % time
|
||||||
else:
|
else:
|
||||||
return '%s %s' % (' ;; '.join(results), time)
|
return '%s %s' % (' :: '.join(results), time)
|
||||||
|
|
||||||
def googlelicensekey(self, irc, msg, args):
|
def googlelicensekey(self, irc, msg, args):
|
||||||
"""<key>
|
"""<key>
|
||||||
@ -102,7 +109,11 @@ class Google(callbacks.Privmsg):
|
|||||||
googlelicensekey = privmsgs.checkCapability(googlelicensekey, 'admin')
|
googlelicensekey = privmsgs.checkCapability(googlelicensekey, 'admin')
|
||||||
|
|
||||||
def google(self, irc, msg, args):
|
def google(self, irc, msg, args):
|
||||||
"<search string>"
|
"""<search string>
|
||||||
|
|
||||||
|
Searches google.com for the given string. As many results as can fit
|
||||||
|
are included.
|
||||||
|
"""
|
||||||
searchString = privmsgs.getArgs(args)
|
searchString = privmsgs.getArgs(args)
|
||||||
data = google.doGoogleSearch(searchString,
|
data = google.doGoogleSearch(searchString,
|
||||||
language='lang_en',
|
language='lang_en',
|
||||||
|
Loading…
Reference in New Issue
Block a user