From 289f614bfa9eebefe5e65df52fed13bcdd283074 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Tue, 19 Nov 2013 10:20:32 +0000 Subject: [PATCH] Web: Make choice of displayed domain (origin/target) configurable. --- plugins/Web/config.py | 4 ++++ plugins/Web/plugin.py | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/Web/config.py b/plugins/Web/config.py index 2e1ef1847..e27f0da29 100644 --- a/plugins/Web/config.py +++ b/plugins/Web/config.py @@ -52,6 +52,10 @@ conf.registerChannelValue(Web, 'titleSnarfer', conf.registerChannelValue(Web, 'snarferReportIOExceptions', registry.Boolean(False, _("""Determines whether the bot will notfiy the user 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', 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 diff --git a/plugins/Web/plugin.py b/plugins/Web/plugin.py index ea6493195..1337313dd 100644 --- a/plugins/Web/plugin.py +++ b/plugins/Web/plugin.py @@ -151,7 +151,9 @@ class Web(callbacks.PluginRegexp): self.log.debug('Encountered a problem parsing %u. Title may ' 'already be set, though', url) 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()) if sys.version_info[0] < 3: if isinstance(title, unicode):