diff --git a/others/google.py b/others/google.py index 78381657c..e157ca39c 100644 --- a/others/google.py +++ b/others/google.py @@ -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): diff --git a/plugins/Google.py b/plugins/Google.py index c57c925bf..03ce3f491 100644 --- a/plugins/Google.py +++ b/plugins/Google.py @@ -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) diff --git a/test/test_Google.py b/test/test_Google.py index d54c78936..ecf62ee60 100644 --- a/test/test_Google.py +++ b/test/test_Google.py @@ -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.'