diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-02-10 13:28:12 +0100 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-02-10 22:08:10 +0100 |
commit | 4d0b0d3554bac832f3c429230b2cbb132ec8b643 (patch) | |
tree | 0ef510544ea6c1514507ccbcc4edc1a3c5514047 /data | |
parent | c2ba27c11d4d7f2a218ea58cb0195e64c626f691 (diff) |
rss plugin: implement and use select_nonempty to grab correct category and author fields
Diffstat (limited to 'data')
-rw-r--r-- | data/rbot/plugins/rss.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/data/rbot/plugins/rss.rb b/data/rbot/plugins/rss.rb index 633e8b21..cf08825f 100644 --- a/data/rbot/plugins/rss.rb +++ b/data/rbot/plugins/rss.rb @@ -812,6 +812,12 @@ class RSSFeedsPlugin < Plugin return seconds
end
+ def select_nonempty(*ar)
+ debug ar
+ ret = ar.map { |i| (i && i.empty?) ? nil : i }.compact.first
+ (ret && ret.empty?) ? nil : ret
+ end
+
def printFormattedRss(feed, item, opts=nil)
debug item
places = feed.watchers
@@ -879,10 +885,8 @@ class RSSFeedsPlugin < Plugin link = item.link.href rescue item.link.chomp rescue nil
- category = item.category.content rescue item.dc_subject rescue nil
- category = nil if category and category.empty?
- author = item.author.name.content rescue item.dc_creator rescue item.author rescue nil
- author = nil if author and author.empty?
+ category = select_nonempty((item.category.content rescue nil), (idem.dc_subject rescue nil))
+ author = select_nonempty((item.author.name.content rescue nil), (item.dc_creator rescue nil), (item.author rescue nil))
line1 = nil
line2 = nil
|