Web: Make choice of displayed domain (origin/target) configurable.

This commit is contained in:
Valentin Lorentz 2013-11-19 10:20:32 +00:00
parent 11d8f4655b
commit 289f614bfa
2 changed files with 7 additions and 1 deletions

View File

@ -52,6 +52,10 @@ conf.registerChannelValue(Web, 'titleSnarfer',
conf.registerChannelValue(Web, 'snarferReportIOExceptions', conf.registerChannelValue(Web, 'snarferReportIOExceptions',
registry.Boolean(False, _("""Determines whether the bot will notfiy the user registry.Boolean(False, _("""Determines whether the bot will notfiy the user
about network exceptions like hostnotfound, timeout ...."""))) about network exceptions like hostnotfound, timeout ....""")))
conf.registerChannelValue(Web, 'snarferShowTargetDomain',
registry.Boolean(False, _("""Determines whether the domain name displayed
by the snarfer will be the original one (posted on IRC) or the target one
(got after following redirects, if any).""")))
conf.registerChannelValue(Web, 'nonSnarfingRegexp', conf.registerChannelValue(Web, 'nonSnarfingRegexp',
registry.Regexp(None, _("""Determines what URLs matching the given regexp registry.Regexp(None, _("""Determines what URLs matching the given regexp
will not be snarfed. Give the empty string if you have no URLs that you'd will not be snarfed. Give the empty string if you have no URLs that you'd

View File

@ -151,7 +151,9 @@ class Web(callbacks.PluginRegexp):
self.log.debug('Encountered a problem parsing %u. Title may ' self.log.debug('Encountered a problem parsing %u. Title may '
'already be set, though', url) 'already be set, though', url)
if parser.title: if parser.title:
domain = utils.web.getDomain(fd.geturl()) domain = utils.web.getDomain(fd.geturl()
if self.registryValue('snarferShowTargetDomain', channel)
else url)
title = utils.web.htmlToText(parser.title.strip()) title = utils.web.htmlToText(parser.title.strip())
if sys.version_info[0] < 3: if sys.version_info[0] < 3:
if isinstance(title, unicode): if isinstance(title, unicode):