66. Earthquake.init do
...
input_filter do |text|
if text =~ /^:(update|reply|retweet|message)/ && text.size > 140
puts "shortening urls...".c(:info)
text.gsub(URI.regexp(['http','https'])) do |url|
query = "domain=#{config[:bitly]
[:domain]}&longUrl=#{URI.encode(url)}&login=#{config[:bitly]
[:username]}&apiKey=#{config[:bitly][:api_key]}"
result = JSON.parse(Net::HTTP.get("api.bit.ly", "/v3/shorten?#{query}"))
if result['status_code'] == 200
result['data']['url']
else
url
end
end
else
text
end
url shorter with bit.ly
end
end