annotate app/lib/clients.rb @ 227:e8eb5caae9c1

Use a different account
author nanaya <me@nanaya.pro>
date Sun, 03 Apr 2022 21:09:58 +0900
parents 17461f7682a2
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
219
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
1 class Clients
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
2 def self.client_options(id)
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
3 {
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
4 :timeouts => {
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
5 :connect => 5,
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
6 :read => 5,
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
7 :write => 5,
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
8 },
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
9 }.merge $cfg[:twitter][id]
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
10 end
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
11
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
12 def self.instance
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
13 @@instance ||= self.new
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
14 end
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
15
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
16 def initialize
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
17 @clients = {}
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
18 end
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
19
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
20 def get(id)
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
21 @clients[id] ||= Twitter::REST::Client.new(self.class.client_options id)
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
22 end
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
23 end