]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/rss.rb
added 'alias rm' as alternative for 'alias remove'
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / rss.rb
index 22b562955fcc34f0a41d38a77a89da5743d0da70..ed37965036ff4abfadd6fe60fba50bb4ab32f671 100644 (file)
@@ -16,8 +16,6 @@
 \r
 require 'rss'\r
 \r
-# Add support for Slashdot namespace in RDF. The code is just an adaptation of\r
-# the DublinCore code.\r
 module ::RSS\r
 \r
   # Make an  'unique' ID for a given item, based on appropriate bot options\r
@@ -30,6 +28,8 @@ module ::RSS
     [item.title, item.link, desc].hash\r
   end\r
 \r
+  # Add support for Slashdot namespace in RDF. The code is just an adaptation\r
+  # of the DublinCore code.\r
   unless defined?(SLASH_PREFIX)\r
     SLASH_PREFIX = 'slash'\r
     SLASH_URI = "http://purl.org/rss/1.0/modules/slash/"\r
@@ -230,11 +230,11 @@ end
 \r
 class RSSFeedsPlugin < Plugin\r
   BotConfig.register BotConfigIntegerValue.new('rss.head_max',\r
-    :default => 30, :validate => Proc.new{|v| v > 0 && v < 200},\r
+    :default => 100, :validate => Proc.new{|v| v > 0 && v < 200},\r
     :desc => "How many characters to use of a RSS item header")\r
 \r
   BotConfig.register BotConfigIntegerValue.new('rss.text_max',\r
-    :default => 90, :validate => Proc.new{|v| v > 0 && v < 400},\r
+    :default => 200, :validate => Proc.new{|v| v > 0 && v < 400},\r
     :desc => "How many characters to use of a RSS item text")\r
 \r
   BotConfig.register BotConfigIntegerValue.new('rss.thread_sleep',\r
@@ -778,15 +778,17 @@ class RSSFeedsPlugin < Plugin
       end\r
     end\r
 \r
-    title = "#{Bold}#{item.title.ircify_html}#{Bold}" if item.title\r
+    title = "#{Bold}#{item.title.ircify_html :limit => @bot.config['rss.head_max']}#{Bold}" if item.title\r
 \r
-    desc = item.description.ircify_html(:a_href => :link_out) if item.description\r
+    desc = item.description.ircify_html(:limit => @bot.config['rss.text_max'], :a_href => :link_out) if item.description\r
 \r
     link = item.link.chomp if item.link\r
 \r
     debug item.inspect\r
-    category = item.dc_subject rescue item.category rescue nil\r
+    category = item.dc_subject rescue item.category.content rescue nil\r
+    category = nil if category and category.empty?\r
     author = item.dc_creator rescue item.author rescue nil\r
+    author = nil if author and author.empty?\r
 \r
     line1 = nil\r
     line2 = nil\r
@@ -794,8 +796,9 @@ class RSSFeedsPlugin < Plugin
     at = ((item.title && item.link) ? ' @ ' : '')\r
     case feed.type\r
     when 'blog'\r
+      author << " " if author\r
       abt = category ? "about #{category} " : ""\r
-      line1 = "#{handle}#{date}#{author} blogged #{abt}at #{link}"\r
+      line1 = "#{handle}#{date}#{author}blogged #{abt}at #{link}"\r
       line2 = "#{handle}#{title} - #{desc}"\r
     when 'forum'\r
       line1 = "#{handle}#{date}#{title}#{at}#{link}"\r
@@ -942,6 +945,9 @@ plugin.map 'rss replace :handle :url :type',
 plugin.map 'rss forcereplace :handle :url :type',\r
   :action => 'forcereplace_rss',\r
   :defaults => {:type => nil}\r
+plugin.map 'rss watch :handle [in :chan]',\r
+  :action => 'watch_rss',\r
+  :defaults => {:url => nil, :type => nil}\r
 plugin.map 'rss watch :handle :url :type [in :chan]',\r
   :action => 'watch_rss',\r
   :defaults => {:url => nil, :type => nil}\r