Made sure the snarfer doesn't respond if there's no license key.

This commit is contained in:
Jeremy Fincher 2003-10-22 17:43:04 +00:00
parent d60b3daecb
commit 615ed5c34b
3 changed files with 9 additions and 2 deletions

View File

@ -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):

View File

@ -275,7 +275,10 @@ class Google(callbacks.PrivmsgCommandAndRegexp):
if not self.snarfer:
return
searchString = match.group(1)
data = search(searchString, safeSearch=1)
try:
data = search(searchString, safeSearch=1)
except google.NoLicenseKey:
return
if data.results:
url = data.results[0].URL
irc.reply(msg, url)

View File

@ -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.'