mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-11 12:42:34 +01:00
RSS: Allow @announce add to take URLs as feed names.
This commit is contained in:
parent
da8689c320
commit
fb52b16429
@ -465,7 +465,8 @@ class RSS(callbacks.Plugin):
|
||||
message isn't sent in the channel itself.
|
||||
"""
|
||||
plugin = irc.getCallback('RSS')
|
||||
invalid_feeds = [x for x in feeds if not plugin.get_feed(x)]
|
||||
invalid_feeds = [x for x in feeds if not plugin.get_feed(x)
|
||||
and not utils.web.urlRe.match(x)]
|
||||
if invalid_feeds:
|
||||
irc.error(format(_('These feeds are unknown: %L'),
|
||||
invalid_feeds), Raise=True)
|
||||
@ -477,6 +478,10 @@ class RSS(callbacks.Plugin):
|
||||
irc.replySuccess()
|
||||
for name in feeds:
|
||||
feed = plugin.get_feed(name)
|
||||
if not feed:
|
||||
plugin.register_feed_config(name, name)
|
||||
plugin.register_feed(name, name, True, False)
|
||||
feed = plugin.get_feed(name)
|
||||
plugin.announce_feed(feed, True)
|
||||
add = wrap(add, [('checkChannelCapability', 'op'),
|
||||
many(first('url', 'feedName'))])
|
||||
|
@ -131,6 +131,25 @@ class RSSTestCase(ChannelPluginTestCase):
|
||||
self._feedMsg('rss remove xkcd')
|
||||
feedparser._open_resource = old_open
|
||||
|
||||
def testAnnounceAnonymous(self):
|
||||
old_open = feedparser._open_resource
|
||||
feedparser._open_resource = constant(xkcd_old)
|
||||
try:
|
||||
self.assertNotError('rss announce add http://xkcd.com/rss.xml')
|
||||
self.assertNotError(' ')
|
||||
with conf.supybot.plugins.RSS.waitPeriod.context(1):
|
||||
time.sleep(1.1)
|
||||
self.assertNoResponse(' ')
|
||||
self.assertNoResponse(' ')
|
||||
feedparser._open_resource = constant(xkcd_new)
|
||||
self.assertNoResponse(' ')
|
||||
time.sleep(1.1)
|
||||
self.assertRegexp(' ', 'Chaos')
|
||||
finally:
|
||||
self._feedMsg('rss announce remove http://xkcd.com/rss.xml')
|
||||
self._feedMsg('rss remove http://xkcd.com/rss.xml')
|
||||
feedparser._open_resource = old_open
|
||||
|
||||
def testAnnounceReload(self):
|
||||
old_open = feedparser._open_resource
|
||||
feedparser._open_resource = constant(xkcd_old)
|
||||
|
Loading…
Reference in New Issue
Block a user