RSS: add option to strip url redirects from headlines

Conflicts:
	plugins/RSS/config.py
This commit is contained in:
Daniel Folkinshteyn 2013-05-04 00:01:52 -04:00 committed by Valentin Lorentz
parent 20bef2dcd0
commit e4ddda4aeb
2 changed files with 9 additions and 1 deletions

View File

@ -75,6 +75,9 @@ conf.registerGlobalValue(RSS, 'sortFeedItems',
FeedItemSortOrder('asInFeed', _("""Determines whether feed items should be
sorted by their update timestamp or kept in the same order as they appear
in a feed.""")))
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

View File

@ -32,6 +32,7 @@ import time
import types
import socket
import threading
import re
import supybot.conf as conf
import supybot.utils as utils
@ -145,9 +146,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: