diff --git a/plugins/RSS/plugin.py b/plugins/RSS/plugin.py index a4187af0a..61a011411 100644 --- a/plugins/RSS/plugin.py +++ b/plugins/RSS/plugin.py @@ -324,47 +324,51 @@ class RSS(callbacks.Plugin): irc.replySuccess() remove = wrap(remove, ['feedName']) - def announce(self, irc, msg, args, channel, optlist, rest): - """[] [--remove] [ ...] + class announce(callbacks.Commands): + def list(self, irc, msg, args, channel): + """[] - Adds the list of to the current list of announced feeds in - the channel given. Valid feeds include the names of registered feeds - as well as URLs for a RSS feeds. is only necessary if the - message isn't sent in the channel itself. If no arguments are - specified, replies with the current list of feeds to announce. If - --remove is given, the specified feeds will be removed from the list - of feeds to announce. - """ - remove = False - announce = conf.supybot.plugins.RSS.announce - for (option, _) in optlist: - if option == 'remove': - if not rest: - raise callbacks.ArgumentError - remove = True - def addFeed(feed): - if feed not in feeds: - feeds.add(feed) - def removeFeed(feed): - if feed in feeds: - feeds.remove(feed) - if rest: - if remove: - updater = removeFeed - else: - updater = addFeed - feeds = announce.get(channel)() - for feed in rest: - updater(feed) - announce.get(channel).setValue(feeds) - irc.replySuccess() - elif not rest: + Returns the list of feeds announced in . is + only necessary if the message isn't sent in the channel itself. + """ + announce = conf.supybot.plugins.RSS.announce feeds = format('%L', list(announce.get(channel)())) irc.reply(feeds or 'I am currently not announcing any feeds.') - return - announce = wrap(announce, [('checkChannelCapability', 'op'), - getopts({'remove':''}), - any(first('url', 'feedName'))]) + list = wrap(list, [optional('channel')]) + + def add(self, irc, msg, args, channel, feeds): + """[] [ ...] + + Adds the list of feeds to the current list of announced feeds in + . Valid feeds include the names of registered feeds as + well as URLs for RSS feeds. is only necessary if the + message isn't sent in the channel itself. + """ + announce = conf.supybot.plugins.RSS.announce + S = announce.get(channel)() + for feed in feeds: + S.add(feed) + announce.get(channel).setValue(S) + irc.replySuccess() + add = wrap(add, [('checkChannelCapability', 'op'), + many(first('url', 'feedName'))]) + + def remove(self, irc, msg, args, channel, feeds): + """[] [ ...] + + Removes the list of feeds from the current list of announced feeds + in . Valid feeds include the names of registered feeds as + well as URLs for RSS feeds. is only necessary if the + message isn't sent in the channel itself. + """ + announce = conf.supybot.plugins.RSS.announce + S = announce.get(channel)() + for feed in feeds: + S.discard(feed) + announce.get(channel).setValue(S) + irc.replySuccess() + remove = wrap(remove, [('checkChannelCapability', 'op'), + many(first('url', 'feedName'))]) def rss(self, irc, msg, args, url, n): """ [] diff --git a/plugins/RSS/test.py b/plugins/RSS/test.py index 13c948add..9b1b2db3a 100644 --- a/plugins/RSS/test.py +++ b/plugins/RSS/test.py @@ -1,5 +1,6 @@ ### # Copyright (c) 2002-2004, Jeremiah Fincher +# Copyright (c) 2009, James Vega # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -55,9 +56,9 @@ class RSSTestCase(ChannelPluginTestCase): def testAnnounce(self): self.assertNotError('rss add advogato %s' % url) - self.assertNotError('rss announce advogato') + self.assertNotError('rss announce add advogato') self.assertNotRegexp('rss announce', r'ValueError') - self.assertNotError('rss announce --remove advogato') + self.assertNotError('rss announce remove advogato') self.assertNotError('rss remove advogato') def testRss(self): @@ -81,4 +82,3 @@ class RSSTestCase(ChannelPluginTestCase): # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: -