From d2046a81a222eee74bf0d3a1efda4c7856e4523a Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Fri, 10 Oct 2014 14:41:30 +0000 Subject: [PATCH] RSS: Prevent errors if users do not use @announce add correctly. Closes GH-869. --- plugins/RSS/plugin.py | 8 +++++++- plugins/RSS/test.py | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/RSS/plugin.py b/plugins/RSS/plugin.py index deaf308f0..6b9e579bc 100644 --- a/plugins/RSS/plugin.py +++ b/plugins/RSS/plugin.py @@ -52,6 +52,8 @@ from supybot.i18n import PluginInternationalization, internationalizeDocstring _ = PluginInternationalization('RSS') def get_feedName(irc, msg, args, state): + if ircutils.isChannel(args[0]): + state.errorInvalid('feed name', args[0], 'must not be channel names.') if not registry.isValidRegistryName(args[0]): state.errorInvalid('feed name', args[0], 'Feed names must not include spaces.') @@ -413,9 +415,13 @@ class RSS(callbacks.Plugin): well as URLs for RSS feeds. is only necessary if the 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)] + if invalid_feeds: + irc.error(format(_('These feeds are unknown: %L'), + invalid_feeds), Raise=True) announce = conf.supybot.plugins.RSS.announce S = announce.get(channel)() - plugin = irc.getCallback('RSS') for name in feeds: S.add(name) announce.get(channel).setValue(S) diff --git a/plugins/RSS/test.py b/plugins/RSS/test.py index 0caf828a5..428fe006f 100644 --- a/plugins/RSS/test.py +++ b/plugins/RSS/test.py @@ -89,6 +89,7 @@ class RSSTestCase(ChannelPluginTestCase): 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(' ')