diff options
-rw-r--r-- | data/rbot/plugins/rss.rb | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/data/rbot/plugins/rss.rb b/data/rbot/plugins/rss.rb index f9399816..57bd6113 100644 --- a/data/rbot/plugins/rss.rb +++ b/data/rbot/plugins/rss.rb @@ -185,7 +185,7 @@ end class ::RssBlob attr_accessor :url, :handle, :type, :refresh_rate, :xml, :title, :items, - :mutex, :watchers, :last_fetched, :http_cache + :mutex, :watchers, :last_fetched, :http_cache, :last_success def initialize(url,handle=nil,type=nil,watchers=[], xml=nil, lf = nil) @url = url @@ -203,6 +203,7 @@ class ::RssBlob @items = nil @mutex = Mutex.new @last_fetched = lf + @last_success = nil sanitize_watchers(watchers) end @@ -277,6 +278,10 @@ class RSSFeedsPlugin < Plugin :default => 300, :validate => Proc.new{|v| v > 30}, :desc => "How many seconds to sleep before checking RSS feeds again") + Config.register Config::IntegerValue.new('rss.announce_timeout', + :default => 0, + :desc => "Don't announce watched feed if these many seconds elapsed since the last successful update") + 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") @@ -888,7 +893,13 @@ class RSSFeedsPlugin < Plugin failures = status[:failures] begin debug "fetching #{feed}" - first_run = !feed.last_fetched + + first_run = !feed.last_success + if (@bot.config['rss.announce_timeout'] > 0 && + (Time.now - feed.last_success > @bot.config['rss.announce_timeout'])) + debug "#{feed} wasn't polled for too long, supressing output" + first_run = true + end oldxml = feed.xml ? feed.xml.dup : nil unless fetchRss(feed, nil, feed.http_cache) failures += 1 @@ -1126,6 +1137,7 @@ class RSSFeedsPlugin < Plugin end feed.mutex.synchronize do feed.xml = xml + feed.last_success = Time.now end return true end |