Created
April 29, 2011 22:41
-
-
Save sss/949168 to your computer and use it in GitHub Desktop.
Google URL Shortener for earthquake.gem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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