mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-24 11:42:52 +01:00
Add some sanity checks to RSS plugin:
First: if an rss feed is called without the number of headlines argument, we now have a default number of items it will output. before, it tried to stuff the whole rss feed into the channel, which is quite floody, if more than one 'mores' is set, or if oneToOne is false. Second: when adding a new feed to announce, it again, tried to stuff the whole rss feed into the channel, which ran into the same floody conditions as above. now we have a default number of feeds to output when there's no cached history.
This commit is contained in:
parent
3005752c58
commit
55eeb4a57b
@ -70,6 +70,13 @@ conf.registerChannelValue(RSS, 'showLinks',
|
|||||||
along with the title of the feed when the rss command is called.
|
along with the title of the feed when the rss command is called.
|
||||||
supybot.plugins.RSS.announce.showLinks affects whether links will be
|
supybot.plugins.RSS.announce.showLinks affects whether links will be
|
||||||
listed when a feed is automatically announced."""))
|
listed when a feed is automatically announced."""))
|
||||||
|
conf.registerGlobalValue(RSS, 'defaultNumberOfHeadlines',
|
||||||
|
registry.PositiveInteger(1, """Indicates how many headlines an rss feed
|
||||||
|
will output by default, if no number is provided."""))
|
||||||
|
conf.registerChannelValue(RSS, 'initialAnnounceHeadlines',
|
||||||
|
registry.PositiveInteger(5, """Indicates how many headlines an rss feed
|
||||||
|
will output when it is first added to announce for a channel."""))
|
||||||
|
|
||||||
|
|
||||||
conf.registerGroup(RSS, 'announce')
|
conf.registerGroup(RSS, 'announce')
|
||||||
conf.registerChannelValue(RSS.announce, 'showLinks',
|
conf.registerChannelValue(RSS.announce, 'showLinks',
|
||||||
|
@ -183,6 +183,8 @@ class RSS(callbacks.Plugin):
|
|||||||
newheadlines = filter(None, newheadlines) # Removes Nones.
|
newheadlines = filter(None, newheadlines) # Removes Nones.
|
||||||
if newheadlines:
|
if newheadlines:
|
||||||
for channel in channels:
|
for channel in channels:
|
||||||
|
if len(oldheadlines) == 0:
|
||||||
|
newheadlines = newheadlines[:self.registryValue('initialAnnounceHeadlines', channel)]
|
||||||
bold = self.registryValue('bold', channel)
|
bold = self.registryValue('bold', channel)
|
||||||
sep = self.registryValue('headlineSeparator', channel)
|
sep = self.registryValue('headlineSeparator', channel)
|
||||||
prefix = self.registryValue('announcementPrefix', channel)
|
prefix = self.registryValue('announcementPrefix', channel)
|
||||||
@ -392,6 +394,8 @@ class RSS(callbacks.Plugin):
|
|||||||
headlines = self.buildHeadlines(headlines, channel, 'showLinks')
|
headlines = self.buildHeadlines(headlines, channel, 'showLinks')
|
||||||
if n:
|
if n:
|
||||||
headlines = headlines[:n]
|
headlines = headlines[:n]
|
||||||
|
else:
|
||||||
|
headlines = headlines[:self.registryValue('defaultNumberOfHeadlines')]
|
||||||
sep = self.registryValue('headlineSeparator', channel)
|
sep = self.registryValue('headlineSeparator', channel)
|
||||||
if self.registryValue('bold', channel):
|
if self.registryValue('bold', channel):
|
||||||
sep = ircutils.bold(sep)
|
sep = ircutils.bold(sep)
|
||||||
|
Loading…
Reference in New Issue
Block a user