From c9825354a325085251df81dd6bc6dcdd37c70756 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Sat, 16 May 2009 15:59:28 +0200 Subject: rss plugin: categories Some feeds have more than one category. Make all of them available in the :categories stream key. --- data/rbot/plugins/rss.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'data/rbot') diff --git a/data/rbot/plugins/rss.rb b/data/rbot/plugins/rss.rb index 1b12632a..fc3082e8 100644 --- a/data/rbot/plugins/rss.rb +++ b/data/rbot/plugins/rss.rb @@ -174,6 +174,13 @@ module ::RSS :dc_creator => %w{dc_creator} }.each { |name, chain| def_bang name, chain } + def categories! + cats = categories.map do |c| + blank2nil { c.content rescue c rescue nil } + end.compact + cats.empty? ? nil : cats + end + protected def blank2nil(&block) x = yield @@ -1112,6 +1119,7 @@ class RSSFeedsPlugin < Plugin link = item.link! link.strip! if link + categories = item.categories! category = item.category! || item.dc_subject! category.strip! if category author = item.dc_creator! || item.author! @@ -1134,6 +1142,7 @@ class RSSFeedsPlugin < Plugin :title => title, :title_wrap => Bold, :desc => desc, :link => link, + :categories => categories, :category => category, :author => author, :at => at } output = @bot.filter(key, stream_hash) -- cgit v1.2.3