From 0d6761f1c61045c9cac50f110b79f6d384410e3d Mon Sep 17 00:00:00 2001 From: James Vega Date: Mon, 3 Jan 2005 04:56:37 +0000 Subject: [PATCH] Change RSS.announce such that it appends the given feeds to its current list of feeds to announce. --- plugins/RSS.py | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/plugins/RSS.py b/plugins/RSS.py index 7cd5a6b37..f297c99ff 100644 --- a/plugins/RSS.py +++ b/plugins/RSS.py @@ -333,37 +333,41 @@ class RSS(callbacks.Privmsg): def announce(self, irc, msg, args, channel, optlist, rest): """[] [--remove] [ ...] - Sets the current list of announced feeds in the channel to the feeds - 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. + 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 - if remove: - if rest: - feeds = announce.get(channel)() - for feed in rest: - if feed in feeds: - feeds.remove(feed) - announce.get(channel).setValue(feeds) - irc.replySuccess() - return + 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: - raise callbacks.ArgumentError + updater = addFeed + feeds = announce.get(channel)() + for feed in rest: + updater(feed) + announce.get(channel).setValue(feeds) + irc.replySuccess() elif not rest: feeds = utils.commaAndify(announce.get(channel)()) irc.reply(feeds or 'I am currently not announcing any feeds.') return - else: - announce.get(channel).setValue(rest) - irc.replySuccess() - return announce = wrap(announce, [('checkChannelCapability', 'op'), getopts({'remove':''}), any('something')])