]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/rss.rb
autoop: Add a 'restore' command that will op anybody that would be autooped.
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / rss.rb
index fac7a9244e1992fea0170588fc261b970e56e5bc..cabc8272f23ab7e77f24d576554a2beae84ead27 100644 (file)
@@ -174,6 +174,14 @@ module ::RSS
       :dc_creator => %w{dc_creator}
     }.each { |name, chain| def_bang name, chain }
 
+    def categories!
+      return nil unless self.respond_to? :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
@@ -377,7 +385,7 @@ class RSSFeedsPlugin < Plugin
 
   # Define default output filters (rss types), and load custom ones.
   # Custom filters are looked for in the plugin's default filter locations
-  # and in rss/types under botclass.
+  # and in rss/types.rb under botclass.
   # Preferably, the rss_type method should be used in these files, e.g.:
   #   rss_type :my_type do |s|
   #     line1 = "%{handle} and some %{author} info"
@@ -1112,6 +1120,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!
@@ -1128,12 +1137,13 @@ class RSSFeedsPlugin < Plugin
     stream_hash = {
       :item => item,
       :handle => handle,
-      :handle_wrap => '::',
+      :handle_wrap => ['::', ':: '],
       :date => date,
       :date_wrap => [nil, ' :: '],
       :title => title,
       :title_wrap => Bold,
       :desc => desc, :link => link,
+      :categories => categories,
       :category => category, :author => author, :at => at
     }
     output = @bot.filter(key, stream_hash)