Skip to content

Instantly share code, notes, and snippets.

@ryumu
Created April 6, 2011 15:03
Show Gist options
  • Save ryumu/905800 to your computer and use it in GitHub Desktop.
Save ryumu/905800 to your computer and use it in GitHub Desktop.
twitpic earthquake.gem plugin
# coding: UTF-8
# earthquake.gem plugin
# upload image on twitpic
# ====
#
# :twitpic message++/path/to/image
Earthquake.init do
require 'twitpic'
config[:twitpic] ||= {}
config[:twitpic][:username] ||= ''
config[:twitpic][:password] ||= ''
config[:twitpic][:separator] ||= '++'
@twitpic = TwitPic.new(config[:twitpic][:username],config[:twitpic][:password])
command /^:twitpic (.*)#{Regexp.escape(config[:twitpic][:separator])}(.+)$/, :as => :twitpic do |m|
path = m[2].gsub(/\\(.)/) {|n| n[1] == '\\' ? '\\' : n[1]}
if confirm("twitpic '#{m[1]} - #{path}'")
async_e do
url = @twitpic.upload(path)[:mediaurl]
twitter.update "#{m[1]} #{url}"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment