mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 11:09:23 +01:00
RSS: add option to strip url redirects from headlines
Conflicts: plugins/RSS/config.py
This commit is contained in:
parent
20bef2dcd0
commit
e4ddda4aeb
@ -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
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user