#
# 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'
DESC = "&description=%{desc}"
REBLOG = "&post-id=%{id}&reblog-key=%{reblog}"
COMMENT = "&comment=%{desc}"
+ TAGS = "&tags=%{tags}"
def help(plugin, topic="")
case topic
line = "<#{nick}> #{line}"
end
html_line = line ? CGI.escapeHTML(line) : line
+ tags = line ? line.scan(/\[([^\]]+)\]/).flatten : []
req = LOGIN % account
ready = false
req << (data % {
:id => id,
:reblog => reblog,
- :desc => CGI.escape(htmlline)
+ :desc => CGI.escape(html_line)
})
ready = true
end
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
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
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\-.]+/}