Google: Rename safeSearch to searchFilter to ease upgrades

This commit is contained in:
James Vega 2009-02-09 05:41:16 +00:00
parent 0c42ea111a
commit 8d21b7a8cf
2 changed files with 10 additions and 10 deletions

View File

@ -98,9 +98,9 @@ conf.registerChannelValue(Google, 'maximumResults',
conf.registerChannelValue(Google, 'defaultLanguage', conf.registerChannelValue(Google, 'defaultLanguage',
Language('lang_en', """Determines what default language is used in Language('lang_en', """Determines what default language is used in
searches. If left empty, no specific language will be requested.""")) searches. If left empty, no specific language will be requested."""))
conf.registerChannelValue(Google, 'safeSearch', conf.registerChannelValue(Google, 'searchFilter',
SafeSearch('moderate', """Determines what level of safeSearch to use by SafeSearch('moderate', """Determines what level of search filtering to use
default. 'active' - most filtering, 'moderate' - default filtering, 'off' by default. 'active' - most filtering, 'moderate' - default filtering,
- no filtering""")) 'off' - no filtering"""))
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:

View File

@ -81,7 +81,7 @@ class Google(callbacks.PluginRegexp):
Valid options are: Valid options are:
smallsearch - True/False (Default: False) smallsearch - True/False (Default: False)
safesearch - {active,moderate,off} (Default: "moderate") filter - {active,moderate,off} (Default: "moderate")
language - Restrict search to documents in the given language language - Restrict search to documents in the given language
(Default: "lang_en") (Default: "lang_en")
""" """
@ -98,7 +98,7 @@ class Google(callbacks.PluginRegexp):
opts['rsz'] = 'small' opts['rsz'] = 'small'
else: else:
opts['rsz'] = 'large' opts['rsz'] = 'large'
elif k == 'safesearch': elif k == 'filter':
opts['safe'] = v opts['safe'] = v
elif k == 'language': elif k == 'language':
opts['lr'] = v opts['lr'] = v
@ -106,7 +106,7 @@ class Google(callbacks.PluginRegexp):
if 'lr' not in opts and defLang: if 'lr' not in opts and defLang:
opts['lr'] = defLang opts['lr'] = defLang
if 'safe' not in opts: if 'safe' not in opts:
opts['safe'] = self.registryValue('safeSearch', dynamic.channel) opts['safe'] = self.registryValue('searchFilter', dynamic.channel)
if 'rsz' not in opts: if 'rsz' not in opts:
opts['rsz'] = 'large' opts['rsz'] = 'large'
@ -154,10 +154,10 @@ class Google(callbacks.PluginRegexp):
lucky = wrap(lucky, ['text']) lucky = wrap(lucky, ['text'])
def google(self, irc, msg, args, optlist, text): def google(self, irc, msg, args, optlist, text):
"""<search> [--{safesearch,language} <value>] """<search> [--{filter,language} <value>]
Searches google.com for the given string. As many results as can fit Searches google.com for the given string. As many results as can fit
are included. --language accepts a language abbreviation; --safesearch are included. --language accepts a language abbreviation; --filter
accepts a filtering level ('active', 'moderate', 'off'). accepts a filtering level ('active', 'moderate', 'off').
""" """
if 'language' in optlist and optlist['language'].lower() not in \ if 'language' in optlist and optlist['language'].lower() not in \
@ -172,7 +172,7 @@ class Google(callbacks.PluginRegexp):
irc.reply(self.formatData(data['responseData']['results'], irc.reply(self.formatData(data['responseData']['results'],
bold=bold, max=max)) bold=bold, max=max))
google = wrap(google, [getopts({'language':'something', google = wrap(google, [getopts({'language':'something',
'safesearch':''}), 'filter':''}),
'text']) 'text'])
def cache(self, irc, msg, args, url): def cache(self, irc, msg, args, url):