ohld / igbot

🐙 Free scripts, bots and Python API wrapper. Get free followers with our auto like, auto follow and other scripts!
https://hikerapi.com/p/N2P6iqiM
Apache License 2.0
4.71k stars 1.47k forks source link

Increase sleep time when 429 error occurs #1182

Closed bruvv closed 4 years ago

bruvv commented 4 years ago

Purpose of your issue?


Describe your issue

When we hit a 429 error because something went to wrong and we got soft banned. A 5 minute sleep will be initiated. After 5 minutes it will be tried again. If we are still soft banned, we have another 5 minutes of sleep. What I want to do but I am unable to make myself is that if a second time this sleep occurs, add 5 minutes to it so the timer creeps up. First time it is 5 minutes, second time it is 10 minutes etc...

I tried to change this line: https://github.com/instagrambot/instabot/blob/master/instabot/api/api.py#L491 To: (added the + sign)

sleep_minutes += 5

but that didn't work.

duplicate-issues[bot] commented 4 years ago

Hey @bruvv,

We did a quick check and this issue looks very darn similar to

This could be a coincidence, but if any of these issues solves your problem then I did a good job :smile:

If not, the maintainers will get to this issue shortly.

Cheers, Your Friendly Neighborhood ProBot

uzairzia commented 4 years ago

@bruvv One thing you could do is add an argument in the function definition of send_request() that passes the current sleep_minutes to the recursively called send_request(). Something like this:

Function Definition

def send_request(  # noqa: C901
        self,
        endpoint,
        post=None,
        login=False,
        with_signature=True,
        headers=None,
        extra_sig=None,
        sleep_minutes=None,
    ):

Since the first time that the function is called, sleep_minutes will most likely be None. Therefore: Somewhere Here

if sleep_minutes is None:
        sleep_minutes = 0

sleep_minutes = sleep_minutes + 5

In the where the function is recursively called, Recursive Call

return self.send_request(
                    endpoint, 
                    post, 
                    login, 
                    with_signature, 
                    headers, 
                    extra_sig, 
                    sleep_minutes
                )
bruvv commented 4 years ago

That is a very good one. I made a PR thanks. https://github.com/instagrambot/instabot/pull/1199