diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2009-02-27 21:40:16 +0100 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2009-02-28 02:23:08 +0100 |
commit | 247d464f127ce711649ab7d7b1969adfaa730efd (patch) | |
tree | ceecc031430e2e05fdc12f94ade32104f7195507 /data/rbot/plugins | |
parent | 24aaf8420ae97367db50b00277bee1f2fa08174c (diff) |
rss plugin: upper limit for watched feeds
Config option to set the maximum number of items that will be announced
when a feed updates. 0 means all of them, anything else clips the list
to the latest ones, and also announces that some of the updates will not
be listed.
Diffstat (limited to 'data/rbot/plugins')
-rw-r--r-- | data/rbot/plugins/rss.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/data/rbot/plugins/rss.rb b/data/rbot/plugins/rss.rb index bfc700d3..30d09bd3 100644 --- a/data/rbot/plugins/rss.rb +++ b/data/rbot/plugins/rss.rb @@ -282,6 +282,10 @@ class RSSFeedsPlugin < Plugin :default => 0, :desc => "Don't announce watched feed if these many seconds elapsed since the last successful update") + Config.register Config::IntegerValue.new('rss.announce_max', + :default => 3, + :desc => "Maximum number of new items to announce when a watched feed is updated") + Config.register Config::BooleanValue.new('rss.show_updated', :default => true, :desc => "Whether feed items for which the description was changed should be shown as new") @@ -957,7 +961,19 @@ class RSSFeedsPlugin < Plugin } if dispItems.length > 0 + max = @bot.config['rss.announce_max'] debug "Found #{dispItems.length} new items in #{feed}" + if max > 0 and dispItems.length > max + debug "showing only the latest #{dispItems.length}" + feed.watchers.each do |loc| + @bot.say loc, (_("feed %{feed} had %{num} updates, showing the latest %{max}") % { + :feed => feed.handle, + :num => dispItems.length, + :max => max + }) + end + dispItems.slice!(max..-1) + end # When displaying watched feeds, publish them from older to newer dispItems.reverse.each { |item| printFormattedRss(feed, item) |