· 6 years ago · Aug 26, 2019, 09:56 AM
1require "rubygems"
2require "twitter"
3
4# get these from apps.twitter.com
5CONSUMER_KEY = "foo"
6CONSUMER_SECRET = "bar"
7OAUTH_TOKEN = "blee"
8OAUTH_TOKEN_SECRET = "baz"
9
10TWITTER_USER = "your_username" # needs to be the one associated with keys above
11
12client = Twitter::REST::Client.new do |config|
13 config.consumer_key = CONSUMER_KEY
14 config.consumer_secret = CONSUMER_SECRET
15 config.access_token = OAUTH_TOKEN
16 config.access_token_secret = OAUTH_TOKEN_SECRET
17end
18
19following_ids = client.friend_ids(TWITTER_USER).to_a
20
21puts "?"
22
23following_ids.each do |id|
24 begin
25 unless client.user(id).to_s == "17275139" # can't miss my dad's retweets ?
26 puts "Disabling RTs from your pal #{client.user(id).screen_name}"
27 client.friendship_update(client.user(id), {:retweets => false})
28 end
29 rescue Twitter::Error::TooManyRequests => error
30 puts "Got an error, probably rate-limiting... waiting #{error.rate_limit.reset_in} seconds to try again"
31 sleep(error.rate_limit.reset_in)
32 retry
33 end
34end
35
36puts "Done!"