summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2009-01-26 00:47:04 +0100
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2009-01-26 00:54:50 +0100
commitdaf0eb2988d71f347b236ba77e43c51735ec2d3f (patch)
tree07756236a23ad98323da84bfeab7e09b867aab95 /data
parent97c72c8f70889a3466d26f295b554b92ca37d146 (diff)
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.
Diffstat (limited to 'data')
-rw-r--r--data/rbot/plugins/rss.rb16
1 files 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