mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-25 19:44:13 +01:00
RSS: Add var supybot.plugins.RSS.maximumAnnounceHeadlines.
This commit is contained in:
parent
0998651f61
commit
eaa5a5523e
@ -93,6 +93,9 @@ conf.registerGlobalValue(RSS, 'sortFeedItems',
|
|||||||
conf.registerChannelValue(RSS, 'notice',
|
conf.registerChannelValue(RSS, 'notice',
|
||||||
registry.Boolean(False, _("""Determines whether announces will be sent
|
registry.Boolean(False, _("""Determines whether announces will be sent
|
||||||
as notices instead of privmsgs.""")))
|
as notices instead of privmsgs.""")))
|
||||||
|
conf.registerChannelValue(RSS, 'maximumAnnounceHeadlines',
|
||||||
|
registry.PositiveInteger(5, _("""Indicates how many new news entries may
|
||||||
|
be sent at the same time. Extra entries will be discarded.""")))
|
||||||
|
|
||||||
####################
|
####################
|
||||||
# Headlines filtering
|
# Headlines filtering
|
||||||
|
@ -367,13 +367,12 @@ class RSS(callbacks.Plugin):
|
|||||||
if feed.name not in self.registryValue('announce', channel):
|
if feed.name not in self.registryValue('announce', channel):
|
||||||
continue
|
continue
|
||||||
if initial:
|
if initial:
|
||||||
n = self.registryValue('initialAnnounceHeadlines', channel)
|
max_entries = \
|
||||||
if n:
|
self.registryValue('initialAnnounceHeadlines', channel)
|
||||||
announced_entries = new_entries[0:n]
|
|
||||||
else:
|
|
||||||
announced_entries = []
|
|
||||||
else:
|
else:
|
||||||
announced_entries = new_entries
|
max_entries = \
|
||||||
|
self.registryValue('maximumAnnounceHeadlines', channel)
|
||||||
|
announced_entries = new_entries[0:max_entries]
|
||||||
announced_entries = sort_feed_items(announced_entries, order)
|
announced_entries = sort_feed_items(announced_entries, order)
|
||||||
for entry in announced_entries:
|
for entry in announced_entries:
|
||||||
self.announce_entry(irc, channel, feed, entry)
|
self.announce_entry(irc, channel, feed, entry)
|
||||||
|
@ -134,6 +134,30 @@ class RSSTestCase(ChannelPluginTestCase):
|
|||||||
self._feedMsg('rss remove xkcd')
|
self._feedMsg('rss remove xkcd')
|
||||||
feedparser._open_resource = old_open
|
feedparser._open_resource = old_open
|
||||||
|
|
||||||
|
def testMaxAnnounces(self):
|
||||||
|
old_open = feedparser._open_resource
|
||||||
|
feedparser._open_resource = constant(xkcd_old)
|
||||||
|
try:
|
||||||
|
self.assertError('rss announce add xkcd')
|
||||||
|
self.assertNotError('rss add xkcd http://xkcd.com/rss.xml')
|
||||||
|
self.assertNotError('rss announce add xkcd')
|
||||||
|
self.assertNotError(' ')
|
||||||
|
with conf.supybot.plugins.RSS.sortFeedItems.context('oldestFirst'):
|
||||||
|
with conf.supybot.plugins.RSS.waitPeriod.context(1):
|
||||||
|
with conf.supybot.plugins.RSS.maximumAnnounceHeadlines.context(1):
|
||||||
|
time.sleep(1.1)
|
||||||
|
self.assertNoResponse(' ')
|
||||||
|
self.assertNoResponse(' ')
|
||||||
|
feedparser._open_resource = constant(xkcd_new)
|
||||||
|
self.assertNoResponse(' ')
|
||||||
|
time.sleep(1.1)
|
||||||
|
self.assertRegexp(' ', 'Telescopes')
|
||||||
|
self.assertNoResponse(' ')
|
||||||
|
finally:
|
||||||
|
self._feedMsg('rss announce remove xkcd')
|
||||||
|
self._feedMsg('rss remove xkcd')
|
||||||
|
feedparser._open_resource = old_open
|
||||||
|
|
||||||
def testAnnounceAnonymous(self):
|
def testAnnounceAnonymous(self):
|
||||||
old_open = feedparser._open_resource
|
old_open = feedparser._open_resource
|
||||||
feedparser._open_resource = constant(xkcd_old)
|
feedparser._open_resource = constant(xkcd_old)
|
||||||
|
Loading…
Reference in New Issue
Block a user