]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/tumblr.rb
quiz: stop quizzes and timers on cleanup
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / tumblr.rb
index e164257e282bb38a3c913eadf0a02a5c517e6b84..755cbce85c909bee6aa657590ca87b6c3692dcf0 100644 (file)
@@ -31,6 +31,7 @@ class TumblrPlugin < Plugin
   DESC = "&description=%{desc}"
   REBLOG = "&post-id=%{id}&reblog-key=%{reblog}"
   COMMENT = "&comment=%{desc}"
+  TAGS = "&tags=%{tags}"
 
   def help(plugin, topic="")
     case topic
@@ -56,6 +57,7 @@ class TumblrPlugin < Plugin
       line = "<#{nick}> #{line}"
     end
     html_line = line ? CGI.escapeHTML(line) : line
+    tags = line ? line.scan(/\[([^\]]+)\]/).flatten : []
 
     req = LOGIN % account
     ready = false
@@ -82,7 +84,7 @@ class TumblrPlugin < Plugin
             req << (data % {
               :id => id,
               :reblog => reblog,
-              :desc => CGI.escape(htmlline)
+              :desc => CGI.escape(html_line)
             })
             ready = true
           end
@@ -105,9 +107,11 @@ class TumblrPlugin < Plugin
           data << NAME if line
         end
       end
+      data << TAGS unless tags.empty?
       req << (data % {
         :src => CGI.escape(url),
         :desc => CGI.escape(html_line),
+        :tags => CGI.escape(tags.join(',')),
         :name => CGI.escape(line)
       })
     end