sferik / twitter-ruby

A Ruby interface to the Twitter API.
http://www.rubydoc.info/gems/twitter
MIT License
4.58k stars 1.31k forks source link

Rate Limit Exceeeded #921

Closed c0ri closed 1 year ago

c0ri commented 6 years ago

Hey guys,

I've noticed recently I'm only able to follow 3-4 people before hitting my rate limit. Doesn't matter how long I wait after the timeout is expired. Today I shut the bot down and it was a good 8 hours before I ran it again with still the same result.

Any ideas appreciated.

I'm using the latest gem.

Thanks!

Essentially I'm doing this:

begin

  (Client.follower_ids.to_a - Client.friend_ids.to_a).each do |user_id|

  [...]

  if (EXCEPTIONS_LIST.include? user_name)

        my_log_action = "#{MY_OWNER}:#{MY_SCREEN_NAME}:Follaback:User #{user_name}(# {user_id}) found in exceptions list. Skipping."

        logAction(my_log_action)

        next

      end

      Client.follow(user_id)

rescue Twitter::Error::TooManyRequests => error

       puts error

       p 'We exceeded our rate limit, sleeping for ' + error.rate_limit.reset_in.to_s + ' seconds before retrying.'

       sleep error.rate_limit.reset_in

       exit
danielgbaena commented 6 years ago

Check out this: https://twittercommunity.com/t/application-rate-limit-status-broken/106429 It seem like there's something broken on Twitter’s end.

danielgbaena commented 6 years ago

I think this is probably already solved: https://twittercommunity.com/t/application-rate-limit-status-broken/106429/12?u=danielgbaena

c0ri commented 6 years ago

I dunno. I just ran my script after an hour or so and could only follow back 4 people before hitting the rate limit. I have some other scripts that seem to follow back with impunity on other accounts 30-40 people at a time with no issues. I really don't want to refactor my code right now to suck down all the 12k followers/friends and sort through them locally. It's not a Dynamic result. Is the method above typically what you guys are doing?