view app/lib/clients.rb @ 237:961d362e42c7 legit-client

The url in entity media isn't unique as they all point to the same thing
author nanaya <me@nanaya.net>
date Sat, 15 Jul 2023 01:47:34 +0900
parents 17461f7682a2
children
line wrap: on
line source

class Clients
  def self.client_options(id)
    {
      :timeouts => {
        :connect => 5,
        :read => 5,
        :write => 5,
      },
    }.merge $cfg[:twitter][id]
  end

  def self.instance
    @@instance ||= self.new
  end

  def initialize
    @clients = {}
  end

  def get(id)
    @clients[id] ||= Twitter::REST::Client.new(self.class.client_options id)
  end
end