RSS: Prevent errors if users do not use @announce add correctly. Closes GH-869.

This commit is contained in:
Valentin Lorentz 2014-10-10 14:41:30 +00:00
parent cb73917a16
commit d2046a81a2
2 changed files with 8 additions and 1 deletions

View File

@ -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. <channel> 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)

View File

@ -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(' ')