mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-02 15:44:06 +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:
|
||||
rc = get(license_key)
|
||||
if rc: return rc
|
||||
usage()
|
||||
#usage()
|
||||
raise NoLicenseKey, 'get a license key at http://www.google.com/apis/'
|
||||
|
||||
def setProxy(http_proxy):
|
||||
|
@ -275,7 +275,10 @@ class Google(callbacks.PrivmsgCommandAndRegexp):
|
||||
if not self.snarfer:
|
||||
return
|
||||
searchString = match.group(1)
|
||||
try:
|
||||
data = search(searchString, safeSearch=1)
|
||||
except google.NoLicenseKey:
|
||||
return
|
||||
if data.results:
|
||||
url = data.results[0].URL
|
||||
irc.reply(msg, url)
|
||||
|
@ -33,6 +33,10 @@ from test import *
|
||||
|
||||
class GoogleTestCase(PluginTestCase, PluginDocumentation):
|
||||
plugins = ('Google',)
|
||||
def testNoNoLicenseKeyError(self):
|
||||
self.irc.feedMsg(ircmsgs.privmsg(self.irc.nick, 'google blah'))
|
||||
self.assertNoResponse(' ')
|
||||
|
||||
def testGroupsSnarfer(self):
|
||||
self.assertRegexp('http://groups.google.com/groups?dq=&hl=en&'
|
||||
'lr=lang_en&ie=UTF-8&oe=UTF-8&selm=698f09f8.'
|
||||
|
Loading…
Reference in New Issue
Block a user