This commit is contained in:
Jeremy Fincher 2003-11-21 12:45:50 +00:00
parent 0da5c27380
commit 308ae5527c
2 changed files with 13 additions and 0 deletions

View File

@ -42,6 +42,7 @@ import getopt
import socket
import urllib2
import SOAP
import google
import conf
@ -119,6 +120,9 @@ def search(*args, **kwargs):
return 'Connection timed out to Google.com.'
else:
raise
except SOAP.faultType, e:
debug.msg(debug.exnToString(e))
raise callbacks.Error, 'Invalid Google license key.'
class Google(callbacks.PrivmsgCommandAndRegexp, plugins.Configurable):
threaded = True
@ -168,6 +172,9 @@ class Google(callbacks.PrivmsgCommandAndRegexp, plugins.Configurable):
is necessary before you can do any searching with this module.
"""
key = privmsgs.getArgs(args)
if len(key) != 32:
irc.error(msg, 'That doesn\'t seem to be a valid license key.')
return
google.setLicense(key)
irc.reply(msg, conf.replySuccess)
licensekey = privmsgs.checkCapability(licensekey, 'admin')

View File

@ -66,6 +66,12 @@ class GoogleTestCase(ChannelPluginTestCase, PluginDocumentation):
'lr=lang_en&ie=UTF-8&oe=UTF-8&selm=698f09f8.'
'0310132012.738e22fc%40posting.google.com')
def testInvalidKeyCaught(self):
self.assertNotError(
'google licensekey abcdefghijklmnopqrstuvwxyz123456')
self.assertNotRegexp('google foobar', 'faultType')
self.assertNotRegexp('google foobar', 'SOAP')
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: