mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-10 20:22:36 +01:00
RSS: Prevent errors if users do not use @announce add correctly. Closes GH-869.
This commit is contained in:
parent
cb73917a16
commit
d2046a81a2
@ -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)
|
||||
|
@ -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(' ')
|
||||
|
Loading…
Reference in New Issue
Block a user