Giter Site home page Giter Site logo

Comments (10)

rhiever avatar rhiever commented on September 8, 2024

That's interesting! I never looked at this except when I was far below 5,000 followers. Now I have to wonder how many people I've unfollowed on accident...

I've confirmed that these calls do indeed only return 5,000 users at a time. Filed this as a bug.

from twitterfollowbot.

rhiever avatar rhiever commented on September 8, 2024

I've started hacking at the code a bit and found a solution, but unfortunately it doesn't seem to scale. I basically work through the cursors to build up a list of all of the user's followers and who they're following. In my case, that's ~40k IDs in both sets, which is about 16 API calls just to populate these lists. As you can imagine, I hit the Twitter API rate limit pretty quick by testing that. And I didn't even do any following/favoriting/etc.

def auto_unfollow_nonfollowers():
    """                                                                                                                                                       
        Unfollows everyone who hasn't followed you back                                                                                                       
    """

    # create a list of all users that the user is following and followed by                                                                                   
    # necessary to use cursors if the user has >5,000 followers or following                                                                                  
    followers_status = t.followers.ids(screen_name=TWITTER_HANDLE)
    followers = set(followers_status["ids"])
    next_cursor = followers_status["next_cursor"]

    while next_cursor != 0:
        followers_status = t.followers.ids(screen_name=TWITTER_HANDLE, cursor=next_cursor)
        followers.update(followers_status["ids"])
        next_cursor = followers_status["next_cursor"]

    following_status = t.friends.ids(screen_name=TWITTER_HANDLE)
    following = set(following_status["ids"])
    next_cursor = following_status["next_cursor"]

    while next_cursor != 0:
        following_status = t.friends.ids(screen_name=TWITTER_HANDLE, cursor=next_cursor)
        following.update(following_status["ids"])
        next_cursor = following_status["next_cursor"]

    # ... rest of the code goes here

Perhaps a more scalable solution is to store the IDs locally and have a one-time "setup" function that users have to call to populate these lists. But that won't be a perfect solution because any follow/unfollow not done through the bot won't be recorded in the list. Furthermore, if anyone unfollows them after the setup, that also won't be reflected in the local list.

In the meantime, I advise against using the auto unfollow functionality if you have over 5,000 followers.

from twitterfollowbot.

Nickfost avatar Nickfost commented on September 8, 2024

I do it on the regular honestly. twitter doesnt limit me and i have accounts with 40k followers.

from twitterfollowbot.

vmunich avatar vmunich commented on September 8, 2024

Hi Randy,

I see that there is a 15 API calls per 15 minutes window limit. If you delay each API call that populates the list of people that don't follow you back, would twitter still block you?

So for example, the function would grab all the cursors/pages until it hits the API limit, wait for 15 minutes, then continue the process.

Another option would be use multiple Twitter Apps/API Keys and switch among them, but I don't think this is a good idea.

What do you think?

from twitterfollowbot.

vmunich avatar vmunich commented on September 8, 2024

Randy,

Please take a look on this:
bear/python-twitter#71

More precisely, the last comment. I will play with that tonight and see what I can get.

from twitterfollowbot.

rhiever avatar rhiever commented on September 8, 2024

@vmunich, please let me know if you have any luck with that method! It seems promising.

from twitterfollowbot.

rhiever avatar rhiever commented on September 8, 2024

Any luck with that method, @vmunich?

from twitterfollowbot.

LouisXavier avatar LouisXavier commented on September 8, 2024

Sorry to jump in on this thread! Did anyone find a solution for this? @vmunich @rhiever? Thanks for your time and help!

from twitterfollowbot.

rhiever avatar rhiever commented on September 8, 2024

Still a standing issue. Haven't had time to dedicate to this bot.

from twitterfollowbot.

rhiever avatar rhiever commented on September 8, 2024

Finally got around to fixing this issue. Cursors ended up being the key to fixing it - now the bot can properly look up all of an accounts follows/followers. However, due to API rate limits, follows/followers now have to be cached locally. I recommend running the new sync_follows() method daily to ensure that the bot is working on a relatively up-to-date cache.

from twitterfollowbot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.