mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-11 20:52:42 +01:00
Google: Fix @lucky.
This commit is contained in:
parent
8321d8a547
commit
de290d12f3
@ -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 = ""
|
||||
|
@ -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')
|
||||
|
Loading…
Reference in New Issue
Block a user