Skip to content

Instantly share code, notes, and snippets.

@ichi
Created October 5, 2011 09:42
Show Gist options
  • Save ichi/1264048 to your computer and use it in GitHub Desktop.
Save ichi/1264048 to your computer and use it in GitHub Desktop.
earthquake plugin: open any url in 1tweet
# -*- coding: utf-8 -*-
Earthquake.init do
command %r{^:open\s+(\d+)\s+(\d+)$}, :as => :open do |m|
num = m[2].to_i
urls = URI.extract(twitter.status(m[1])['text'])
if !urls.empty?
if num <= urls.size
browse urls[num - 1]
else
puts "#{num} links not found (but found #{urls.size})".c(41)
end
else
puts "no link found".c(41)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment