mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-02 07:34:08 +01:00
Made sure the snarfer doesn't respond if there's no license key.
This commit is contained in:
parent
d60b3daecb
commit
615ed5c34b
@ -118,7 +118,7 @@ def getLicense(license_key = None):
|
|||||||
for get, location in _licenseLocations:
|
for get, location in _licenseLocations:
|
||||||
rc = get(license_key)
|
rc = get(license_key)
|
||||||
if rc: return rc
|
if rc: return rc
|
||||||
usage()
|
#usage()
|
||||||
raise NoLicenseKey, 'get a license key at http://www.google.com/apis/'
|
raise NoLicenseKey, 'get a license key at http://www.google.com/apis/'
|
||||||
|
|
||||||
def setProxy(http_proxy):
|
def setProxy(http_proxy):
|
||||||
|
@ -275,7 +275,10 @@ class Google(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
if not self.snarfer:
|
if not self.snarfer:
|
||||||
return
|
return
|
||||||
searchString = match.group(1)
|
searchString = match.group(1)
|
||||||
data = search(searchString, safeSearch=1)
|
try:
|
||||||
|
data = search(searchString, safeSearch=1)
|
||||||
|
except google.NoLicenseKey:
|
||||||
|
return
|
||||||
if data.results:
|
if data.results:
|
||||||
url = data.results[0].URL
|
url = data.results[0].URL
|
||||||
irc.reply(msg, url)
|
irc.reply(msg, url)
|
||||||
|
@ -33,6 +33,10 @@ from test import *
|
|||||||
|
|
||||||
class GoogleTestCase(PluginTestCase, PluginDocumentation):
|
class GoogleTestCase(PluginTestCase, PluginDocumentation):
|
||||||
plugins = ('Google',)
|
plugins = ('Google',)
|
||||||
|
def testNoNoLicenseKeyError(self):
|
||||||
|
self.irc.feedMsg(ircmsgs.privmsg(self.irc.nick, 'google blah'))
|
||||||
|
self.assertNoResponse(' ')
|
||||||
|
|
||||||
def testGroupsSnarfer(self):
|
def testGroupsSnarfer(self):
|
||||||
self.assertRegexp('http://groups.google.com/groups?dq=&hl=en&'
|
self.assertRegexp('http://groups.google.com/groups?dq=&hl=en&'
|
||||||
'lr=lang_en&ie=UTF-8&oe=UTF-8&selm=698f09f8.'
|
'lr=lang_en&ie=UTF-8&oe=UTF-8&selm=698f09f8.'
|
||||||
|
Loading…
Reference in New Issue
Block a user