summaryrefslogtreecommitdiff
path: root/data/rbot/plugins/rss.rb
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2009-05-16 15:59:28 +0200
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2009-05-16 17:09:40 +0200
commitc9825354a325085251df81dd6bc6dcdd37c70756 (patch)
tree5aea0550f1e8a36ab42b719943c53f084032a83e /data/rbot/plugins/rss.rb
parent86c7392e11d95dac44924778d45284d976b42a79 (diff)
rss plugin: categories
Some feeds have more than one category. Make all of them available in the :categories stream key.
Diffstat (limited to 'data/rbot/plugins/rss.rb')
-rw-r--r--data/rbot/plugins/rss.rb9
1 files changed, 9 insertions, 0 deletions
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)