]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
rss plugin: add support for twitter format
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sat, 15 Sep 2007 10:35:34 +0000 (10:35 +0000)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sat, 15 Sep 2007 10:35:34 +0000 (10:35 +0000)
Twitter feeds can use the generic output format, but there is no need to 'cap' their titles because of the hardcoded length limits imposed by Twitter

data/rbot/plugins/rss.rb

index 5e7eff215ace9115f665d2a5a5d0e89b6f71ad6c..22aa742ff6bc3c08f98a1020123f9c8e19ace2f2 100644 (file)
@@ -815,9 +815,18 @@ class RSSFeedsPlugin < Plugin
       end\r
     end\r
 \r
-    title = "#{Bold}#{item.title.ircify_html :limit => @bot.config['rss.head_max']}#{Bold}" if item.title\r
+    tit_opt = {}\r
+    # Twitters don't need a cap on the title length since they have a hard\r
+    # limit to 160 characters, and most of them are under 140 characters\r
+    tit_opt[:limit] = @bot.config['rss.head_max'] unless feed.type == 'twitter'\r
 \r
-    desc = item.description.ircify_html(:limit => @bot.config['rss.text_max'], :a_href => :link_out) if item.description\r
+    title = "#{Bold}#{item.title.ircify_html(tit_opt)}#{Bold}" if item.title\r
+\r
+    desc_opt = {\r
+      :limit => @bot.config['rss.text_max'],\r
+      :a_href => :link_out\r
+    }\r
+    desc = item.description.ircify_html(desc_opt) if item.description\r
 \r
     link = item.link.chomp if item.link\r
 \r