diff --git a/plugins/RSS/config.py b/plugins/RSS/config.py index 597712a17..e4fe98faa 100644 --- a/plugins/RSS/config.py +++ b/plugins/RSS/config.py @@ -62,6 +62,9 @@ conf.registerGlobalValue(RSS, 'waitPeriod', registry.PositiveInteger(1800, """Indicates how many seconds the bot will wait between retrieving RSS feeds; requests made within this period will return cached results.""")) +conf.registerGlobalValue(RSS, 'stripRedirect', registry.Boolean( + True, """Determines whether the bot will attempt to strip url redirection + from headline links, by taking things after the last http://.""")) conf.registerGlobalValue(RSS, 'feeds', FeedNames([], """Determines what feeds should be accessible as diff --git a/plugins/RSS/plugin.py b/plugins/RSS/plugin.py index d60c2fe5c..8ef5a4a11 100644 --- a/plugins/RSS/plugin.py +++ b/plugins/RSS/plugin.py @@ -33,6 +33,7 @@ import time import socket import sgmllib import threading +import re import supybot.conf as conf import supybot.utils as utils @@ -143,9 +144,13 @@ class RSS(callbacks.Plugin): if self.registryValue(config, channel): for headline in headlines: if headline[1]: + if self.registryValue('stripRedirect'): + h = re.sub('^.*http://', 'http://', headline[1]) + else: + h = headline[1] newheadlines.append(format('%s %u', headline[0], - headline[1].encode('utf-8'))) + h.encode('utf-8'))) else: newheadlines.append(format('%s', headline[0])) else: