Google: Configurable base URL. Closes GH-64.

This commit is contained in:
Valentin Lorentz 2013-05-21 18:40:38 +02:00
parent efcf9d7837
commit a15dea55db
2 changed files with 7 additions and 2 deletions

View File

@ -101,6 +101,9 @@ conf.registerGlobalValue(Google, 'referer',
the Referer field of the search requests. If this value is empty, a
Referer will be generated in the following format:
http://$server/$botName""")))
conf.registerChannelValue(Google, 'baseUrl',
registry.String('google.com', _("""Determines the base URL used for
requests.""")))
conf.registerChannelValue(Google, 'searchSnarfer',
registry.Boolean(False, _("""Determines whether the search snarfer is
enabled. If so, messages (even unaddressed ones) beginning with the word

View File

@ -290,13 +290,15 @@ class Google(callbacks.PluginRegexp):
def _googleUrl(self, s):
s = s.replace('+', '%2B')
s = s.replace(' ', '+')
url = r'http://google.com/search?q=' + s
url = r'http://%s/search?q=%s' % \
(self.registryValue('baseUrl', channel), s)
return url
def _googleUrlIG(self, s):
s = s.replace('+', '%2B')
s = s.replace(' ', '+')
url = r'http://www.google.com/ig/calculator?hl=en&q=' + s
url = r'http://%s/ig/calculator?hl=en&q=%s' % \
(self.registryValue('baseUrl', channel), s)
return url
_calcRe1 = re.compile(r'<table.*class="?obcontainer"?[^>]*>(.*?)</table>', re.I)