]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
RSS plugin update.
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Mon, 24 Jul 2006 19:02:37 +0000 (19:02 +0000)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Mon, 24 Jul 2006 19:02:37 +0000 (19:02 +0000)
* Less spammy formatting default for trac entries
* debug line inspecting the item to be formatted
* to_s and to_a methods for RssBlob

data/rbot/plugins/rss.rb

index eaa86505d561ff7e4883377b6542b86450c6ada1..af7901275b2e5a211552a63bd88c0efbc2ef881c 100644 (file)
@@ -69,9 +69,18 @@ class ::RssBlob
     @watchers.delete(who)\r
   end\r
 \r
-  #  def to_ary\r
-  #    [@handle,@url,@type,@watchers]\r
-  #  end\r
+  def to_a\r
+    [@handle,@url,@type,@watchers]\r
+  end\r
+\r
+  def to_s(watchers=false)\r
+    if watchers\r
+      a = self.to_a.flatten\r
+    else\r
+      a = self.to_a[0,3]\r
+    end\r
+    a.join(" | ")\r
+  end\r
 end\r
 \r
 class RSSFeedsPlugin < Plugin\r
@@ -392,6 +401,7 @@ class RSSFeedsPlugin < Plugin
   end\r
 \r
   def printFormattedRss(feed, item)\r
+    debug "Printing formatted item #{item.inspect} for feed #{feed.to_s}"\r
     feed.watchers.each { |loc|\r
       case feed.type\r
       when 'blog'\r
@@ -404,9 +414,8 @@ class RSSFeedsPlugin < Plugin
       when 'gmame'\r
         @bot.say loc, "::#{feed.handle}:: Message #{item.title} sent by #{item.dc_creator}. #{item.description.split("\n")[0].chomp.riphtml.shorten(@bot.config['rss.text_max'])} ::"\r
       when 'trac'\r
-        @bot.say loc, "/---- #{feed.handle} :: #{item.title} :: #{item.link}"\r
-        @bot.say loc, "|#{item.description.gsub(/\s+/,' ').strip.riphtml.shorten(@bot.config['rss.text_max'])}"\r
-        @bot.say loc, "\\----"\r
+        @bot.say loc, "::#{feed.handle}:: #{item.title} :: #{item.link}"\r
+        @bot.say loc, "::#{feed.handle}:: #{item.description.gsub(/\s+/,' ').strip.riphtml.shorten(@bot.config['rss.text_max'])}"\r
       else\r
         printRssItem(loc,item)\r
       end\r