]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/rss.rb
rss: obviously, the precending patch wasn't enough
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / rss.rb
index eb3fa5f86b1bcb60be626006f323b91ac1341a14..6b16361984d3d19056e6e2151316558b396da6c8 100644 (file)
@@ -151,6 +151,28 @@ module ::RSS
     SlashModel::ELEMENTS.collect! {|name| "#{SLASH_PREFIX}_#{name}"}
   end
 
+  if self.const_defined? :Atom
+    # There are improper Atom feeds around that use the non-standard
+    # 'modified' element instead of the correct 'updated' one. Let's
+    # support it too.
+    module Atom
+      class Feed
+        class Modified < RSS::Element
+          include CommonModel
+          include DateConstruct
+        end
+        __send__("install_have_child_element",
+                 "modified", URI, nil, "modified", :content)
+
+        class Entry
+          Modified = Feed::Modified
+          __send__("install_have_child_element",
+                   "modified", URI, nil, "modified", :content)
+        end
+      end
+    end
+  end
+
   class Element
     class << self
       def def_bang(name, chain)
@@ -1079,8 +1101,10 @@ class RSSFeedsPlugin < Plugin
 
     date = \
     if opts[:date]
-      if item.respond_to?(:updated)
+      if item.respond_to?(:updated) and item.updated
         make_date(item.updated.content)
+      elsif item.respond_to?(:modified) and item.modified
+        make_date(item.modified.content)
       elsif item.respond_to?(:source) and item.source.respond_to?(:updated)
         make_date(item.source.updated.content)
       elsif item.respond_to?(:pubDate)