mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-26 03:54:08 +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'
|
_gsearchUrl = 'https://www.google.com/search'
|
||||||
@internationalizeDocstring
|
|
||||||
def search(self, query, channel, options={}):
|
def search(self, query, channel, options={}):
|
||||||
"""Perform a search using Google's AJAX API.
|
"""Perform a search using Google's AJAX API.
|
||||||
search("search phrase", options={})
|
search("search phrase", options={})
|
||||||
@ -170,10 +169,11 @@ class Google(callbacks.PluginRegexp):
|
|||||||
"""
|
"""
|
||||||
opts = dict(opts)
|
opts = dict(opts)
|
||||||
data = self.search(text, msg.args[0], {'smallsearch': True})
|
data = self.search(text, msg.args[0], {'smallsearch': True})
|
||||||
|
data = self.decode(data)
|
||||||
if data:
|
if data:
|
||||||
url = data['url']
|
url = data[0]['url']
|
||||||
if 'snippet' in opts:
|
if 'snippet' in opts:
|
||||||
snippet = data['content']
|
snippet = data[0]['content']
|
||||||
snippet = " | " + utils.web.htmlToText(snippet, tagReplace='')
|
snippet = " | " + utils.web.htmlToText(snippet, tagReplace='')
|
||||||
else:
|
else:
|
||||||
snippet = ""
|
snippet = ""
|
||||||
|
@ -54,6 +54,10 @@ class GoogleTestCase(ChannelPluginTestCase):
|
|||||||
# Unicode check
|
# Unicode check
|
||||||
self.assertNotError('google ae')
|
self.assertNotError('google ae')
|
||||||
|
|
||||||
|
def testLucky(self):
|
||||||
|
self.assertResponse('lucky Hacker News',
|
||||||
|
'https://news.ycombinator.com/')
|
||||||
|
|
||||||
def testSearchFormat(self):
|
def testSearchFormat(self):
|
||||||
self.assertRegexp('google foo', '<https?://.*>')
|
self.assertRegexp('google foo', '<https?://.*>')
|
||||||
self.assertNotError('config reply.format.url %s')
|
self.assertNotError('config reply.format.url %s')
|
||||||
|
Loading…
Reference in New Issue
Block a user