diff options
author | re4k <re4k@re4k.info> | 2013-03-26 17:54:34 +0900 |
---|---|---|
committer | re4k <re4k@re4k.info> | 2013-03-26 17:55:13 +0900 |
commit | 9e05ce53b550ab05d06268bd0c2ae26ad294d0ab (patch) | |
tree | a431e3e1811e32e465a872c3ea9481106b83b2f7 /client | |
parent | 22b478cd66a419c30ab28471fbd495019810469e (diff) | |
download | aclog-9e05ce53b550ab05d06268bd0c2ae26ad294d0ab.tar.gz |
Add favs_from/rts_from
Diffstat (limited to 'client')
-rw-r--r-- | client/worker.rb | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/client/worker.rb b/client/worker.rb index 1ed3414..eeb7bf9 100644 --- a/client/worker.rb +++ b/client/worker.rb @@ -52,19 +52,25 @@ class Worker def receive_account(msg) user_id = msg["user_id"] account_id = msg["id"] + + conopts = {:host => "userstream.twitter.com", + :path => "/1.1/user.json", + :oauth => { + :consumer_key => Settings.consumer[msg["consumer_version"].to_i].key, + :consumer_secret => Settings.consumer[msg["consumer_version"].to_i].secret, + :token => msg["oauth_token"], + :token_secret => msg["oauth_token_secret"]}, + :method => "GET"} if @clients[account_id] - @clients[account_id].connection.stop - @clients.delete(account_id) + unless @clients[account_id].options[:oauth][:token] == conopts[:oauth][:token] + @clients.connection.update(conopts) + $logger.info("Updated(##{account_id}/#{user_id}/#{msg["consumer_version"].to_i})") + else + $logger.info("Not Updated(##{account_id}/#{user_id}/#{msg["consumer_version"].to_i})") + end + return end - @clients[account_id] = client = EM::Twitter::Client.new({ - :host => "userstream.twitter.com", - :path => "/1.1/user.json", - :oauth => { - :consumer_key => Settings.consumer[msg["consumer_version"].to_i].key, - :consumer_secret => Settings.consumer[msg["consumer_version"].to_i].secret, - :token => msg["oauth_token"], - :token_secret => msg["oauth_token_secret"]}, - :method => "GET"}) + @clients[account_id] = client = EM::Twitter::Client.new(conopts) send_user = -> user do out = {:type => "user", @@ -206,7 +212,7 @@ class Worker end client.connect - $logger.info("Connected(##{account_id}/#{user_id})") + $logger.info("Connected(##{account_id}/#{user_id}/#{msg["consumer_version"].to_i})") end def post_init |