Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@sss
Created April 29, 2011 22:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sss/949168 to your computer and use it in GitHub Desktop.
Save sss/949168 to your computer and use it in GitHub Desktop.
Google URL Shortener for earthquake.gem
# Google URL Shortener for earthquake.gem
require 'googl'
Earthquake.init do
_ = config[:googl] ||= {}
_[:username] ||= ''
_[:password] ||= ''
_[:only_long_tweet] ||= false
input_filter do |text|
if text =~ /^:(update|reply)/ && (!_[:only_long_tweet] || text.size > 140)
text.gsub(URI.regexp(['http','https'])) do |url|
client = Googl.client(_[:username], _[:password])
client.shorten(url).short_url
end
else
text
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment