Skip to content

Commit

Permalink
add tumblr reblog plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattn committed Jan 14, 2009
1 parent d6df783 commit 890da98
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions lib/plugin/reblog.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require 'rubygems'
require 'tumblr'

module Termtter::Client
add_help 'reblog ID', 'Tumblr Reblog a status'

add_command %r'^reblog\s+(\d+)(.*)$' do |m, t|
id = m[1]
comment = m[2].strip
statuses = public_storage[:log].select { |s| s.id == id }
unless statuses.empty?
status = statuses.first
else
status = t.show(id).first
end

Tumblr::API.write(configatron.plugins.reblog.email, configatron.plugins.reblog.password) do
quote("#{status.text}", "<a href=\"http://twitter.com/#{status.user_screen_name}/status/#{status.id}\">Twitter / #{status.user_name}</a>")
end
end

add_completion do |input|
%w(reblog).grep(/^#{Regexp.quote input}/)
end
end

# reblog.rb
# tumblr reblog it!
#
# configatron.plugins.reblog.email = 'your-email-on-tumblr'
# configatron.plugins.reblog.password = 'your-password-on-tumblr'
#
# reblog 1114860346

0 comments on commit 890da98

Please sign in to comment.