diff --git a/plugins/RSS/plugin.py b/plugins/RSS/plugin.py index 311a04c4e..03694de5d 100644 --- a/plugins/RSS/plugin.py +++ b/plugins/RSS/plugin.py @@ -514,6 +514,17 @@ class RSS(callbacks.Plugin): irc.error(_('That\'s not a valid RSS feed command name.')) return self.remove_feed(feed) + + # If the feed was first created "anonymously", eg. with + # `@rss announce add http://example.org/rss`, then as a named feed + # with `@rss add example http://example.org/rss`, + # `self.get_feed(name)` above gets only one of them; so let's + # remove the aliased name or URL from the feed names too, + # or we would have a dangling entry here. + self.feed_names.pop(name, None) + self.feed_names.pop(feed.url, None) + assert self.get_feed(name) is None + irc.replySuccess() remove = wrap(remove, ['feedName']) diff --git a/plugins/RSS/test.py b/plugins/RSS/test.py index 3e7a1a7a9..73ebfef2d 100644 --- a/plugins/RSS/test.py +++ b/plugins/RSS/test.py @@ -100,6 +100,17 @@ class RSSTestCase(ChannelPluginTestCase): finally: self.assertNotError('rss remove xkcd') + @mock_urllib + def testRemoveAliasedFeed(self, mock): + try: + self.assertNotError('rss announce add http://xkcd.com/rss.xml') + self.assertNotError('rss add xkcd http://xkcd.com/rss.xml') + finally: + self.assertNotError('rss announce remove http://xkcd.com/rss.xml') + self.assertNotError('rss remove xkcd') + self.assertEqual(self.irc.getCallback('RSS').feed_names, {}) + self.assertEqual(self.irc.getCallback('RSS').feeds, {}) + @mock_urllib def testInitialAnnounceNewest(self, mock): mock._data = xkcd_new