From daf0eb2988d71f347b236ba77e43c51735ec2d3f Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Mon, 26 Jan 2009 00:47:04 +0100 Subject: rss plugin: parseRss returns the number of found items Change the parseRss routine to return the number of found items, or nil in case of error. This helps clearly differentiate between empty feeds (which are still legit) and b0rked feeds. This change in logic does not alter the fact that a feed update with no items will not wipe existing old feed items. --- data/rbot/plugins/rss.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/data/rbot/plugins/rss.rb b/data/rbot/plugins/rss.rb index 27cf2f1d..387546ec 100644 --- a/data/rbot/plugins/rss.rb +++ b/data/rbot/plugins/rss.rb @@ -612,7 +612,7 @@ class RSSFeedsPlugin < Plugin parsed = parseRss(feed, m) end return unless feed.items - m.reply "using old data" unless fetched and parsed + m.reply "using old data" unless fetched and parsed and parsed > 0 title = feed.title items = feed.items @@ -900,9 +900,11 @@ class RSSFeedsPlugin < Plugin uid } - unless parseRss(feed) - debug "no items in feed #{feed}" + nitems = parseRss(feed) + if nitems.nil? failures += 1 + elsif nitems == 0 + debug "no items in feed #{feed}" else debug "Checking if new items are available for #{feed}" failures -= 1 if failures > 0 @@ -1165,11 +1167,11 @@ class RSSFeedsPlugin < Plugin if items.empty? report_problem("no items found in the feed, maybe try weed?", e, m) - return nil + else + feed.title = title.strip + feed.items = items end - feed.title = title.strip - feed.items = items - return true + return items.length end end end -- cgit v1.2.3