# File lib/plugins/tinyurl.rb, line 41
  def self.shorten_url(url, host, format)
    return url if config.plugins.tinyurl.ignore_regexp =~ url # already shorten
    url_enc = URI.escape(url, /[^a-zA-Z0-9.:]/)
    res = Termtter::HTTPpool.start(host) do |h|
      h.get(format % url_enc)
    end
    if res.code == '200'
      result = res.body
      if /"shortUrl": "(http.*)"/ =~ result
        result = $1
      elsif /"statusCode": "ERROR"/ =~ result
        return nil
      end
      result
    else
      nil
    end
  end