diff --git a/plugins/RSS/plugin.py b/plugins/RSS/plugin.py index 14cf6701e..2619dad00 100644 --- a/plugins/RSS/plugin.py +++ b/plugins/RSS/plugin.py @@ -167,10 +167,17 @@ class RSS(callbacks.Plugin): ################## # Feed registering - def assert_feed_does_not_exist(self, name): + def assert_feed_does_not_exist(self, name, url=None): if self.isCommandMethod(name): - s = format('I already have a command in this plugin named %s.',name) + s = format(_('I already have a command in this plugin named %s.'), + name) raise callbacks.Error(s) + if url: + feed = self.feeds.get(url) + if feed and feed.name != feed.url: + s = format(_('I already have a feed with that URL named %s.'), + feed.name) + raise callbacks.Error(s) def register_feed_config(self, name, url=''): self.registryValue('feeds').add(name) @@ -332,7 +339,7 @@ class RSS(callbacks.Plugin): Adds a command to this plugin that will look up the RSS feed at the given URL. """ - self.assert_feed_does_not_exist(name) + self.assert_feed_does_not_exist(name, url) self.register_feed_config(name, url) self.register_feed(name, url, False) irc.replySuccess() diff --git a/plugins/RSS/test.py b/plugins/RSS/test.py index b86e85a49..adb25e87a 100644 --- a/plugins/RSS/test.py +++ b/plugins/RSS/test.py @@ -62,6 +62,13 @@ class RSSTestCase(ChannelPluginTestCase): def testCantRemoveMethodThatIsntFeed(self): self.assertError('rss remove rss') + def testCantAddDuplicatedFeed(self): + self.assertNotError('rss add xkcd http://xkcd.com/rss.xml') + try: + self.assertError('rss add xkcddup http://xkcd.com/rss.xml') + finally: + self.assertNotError('rss remove xkcd') + def testAnnounce(self): old_open = feedparser._open_resource feedparser._open_resource = constant(xkcd_old)