Last active
September 28, 2018 13:18
-
-
Save hiroxto/b2cf15bfddeca7af0bf57881684d6d32 to your computer and use it in GitHub Desktop.
"statuses/home_timeline"の代替になるリストを作る。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 複数アカウントで作れる "hiroto-k/alt-tl" を作ったのでそちらを参照。 | |
# https://github.com/hiroto-k/alt-tl | |
require 'twitter' | |
require 'pp' | |
config = { | |
consumer_key: '', | |
consumer_secret: '', | |
access_token: '', | |
access_token_secret: '', | |
} | |
# リストのID。Integerで指定。 | |
list_id = nil | |
client = Twitter::REST::Client.new(config) | |
puts 'Get current members.' | |
members = client | |
.list_members(list_id, count: 5000) | |
.attrs[:users] | |
.map { |user| | |
user[:id] | |
} | |
puts 'Get current friends.' | |
friend = client | |
.friend_ids(count: 5000) | |
.attrs[:ids] | |
add_accounts = friend - members | |
remove_accounts = members - friend | |
puts 'Adds' | |
pp add_accounts | |
add_accounts.each_slice(100) do |user_ids| | |
client.add_list_members(list_id, user_ids) | |
end | |
puts 'Removes' | |
pp remove_accounts | |
remove_accounts.each_slice(100) do |user_ids| | |
client.remove_list_members(list_id, user_ids) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment