Google: Fix @lucky.

This commit is contained in:
Valentin Lorentz 2016-05-05 09:01:51 +02:00
parent 8321d8a547
commit de290d12f3
2 changed files with 7 additions and 3 deletions

View File

@ -93,7 +93,6 @@ class Google(callbacks.PluginRegexp):
_gsearchUrl = 'https://www.google.com/search'
@internationalizeDocstring
def search(self, query, channel, options={}):
"""Perform a search using Google's AJAX API.
search("search phrase", options={})
@ -170,10 +169,11 @@ class Google(callbacks.PluginRegexp):
"""
opts = dict(opts)
data = self.search(text, msg.args[0], {'smallsearch': True})
data = self.decode(data)
if data:
url = data['url']
url = data[0]['url']
if 'snippet' in opts:
snippet = data['content']
snippet = data[0]['content']
snippet = " | " + utils.web.htmlToText(snippet, tagReplace='')
else:
snippet = ""

View File

@ -54,6 +54,10 @@ class GoogleTestCase(ChannelPluginTestCase):
# Unicode check
self.assertNotError('google ae')
def testLucky(self):
self.assertResponse('lucky Hacker News',
'https://news.ycombinator.com/')
def testSearchFormat(self):
self.assertRegexp('google foo', '<https?://.*>')
self.assertNotError('config reply.format.url %s')