mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-26 20:59:27 +01:00
RSS: add option to strip url redirects from headlines
This commit is contained in:
parent
02a2a056a4
commit
78659113c1
@ -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
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user