summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2010-09-15 15:45:26 +0200
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2010-09-15 15:45:26 +0200
commita490d46226e3b370e719c19004f199d4fcd19fd4 (patch)
treeb90579ed558a66a9d7d69e8abde3a8eb675bd36c
parent501e90085ef5889036899a006796c13110255fe6 (diff)
tumblr: support tags
Tags are specified on the IRC line by putting them between square brakets.
-rw-r--r--data/rbot/plugins/tumblr.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/data/rbot/plugins/tumblr.rb b/data/rbot/plugins/tumblr.rb
index e164257e..e31e9abe 100644
--- a/data/rbot/plugins/tumblr.rb
+++ b/data/rbot/plugins/tumblr.rb
@@ -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
@@ -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