X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Ftumblr.rb;h=515dc479026e26289ffcf5d1c768eeffe741b172;hb=3ace72d5642284665fce2c33c99dfeb1b931b2c6;hp=a135e6c371aac43e7bea760894273901b7301b8e;hpb=3a863b20a43d3013a47dfc3e2081076a3b3ac840;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/tumblr.rb b/data/rbot/plugins/tumblr.rb index a135e6c3..515dc479 100644 --- a/data/rbot/plugins/tumblr.rb +++ b/data/rbot/plugins/tumblr.rb @@ -9,10 +9,10 @@ # # Submit URLs to channel-specific tumblr accounts # -# TODO reblog tumblr URLs -# TODO support video better (e.g. Vimeo or anything else with embed) +# TODO support other video providers (maybe detect embed codes?) # TODO support image better (e.g. pages with a single big image) # TODO customize caption/description format +# TODO do not reblog own posts (maybe?) require 'rexml/document' require 'cgi' @@ -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 @@ -97,7 +99,7 @@ class TumblrPlugin < Plugin data = PHOTO data << CAPTION if line else - if url.match(%r{^http://(\w+\.)?youtube\.com/watch.*}) + if url.match(%r{^http://(\w+\.)?(youtube\.com/watch.*|vimeo.com/\d+)}) data = VIDEO data << CAPTION if line else @@ -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 @@ -184,5 +188,5 @@ plugin.map 'tumblr configure [:channel]', :action => :configuration plugin.map 'tumblr deconfigure [:channel]', :action => :deconfigure plugin.map 'tumblr configure [:channel] :email :pwd [:group]', :action => :configure, - :requirements => {:channel => Regexp::Irc::GEN_CHAN, :email => /.+@.+/, :group => /[A-Za-z-]+/} + :requirements => {:channel => Regexp::Irc::GEN_CHAN, :email => /\S+@\S+/, :group => /[A-Za-z\-.]+/}