alexal1 / Insomniac

Instagram bot for automated Instagram interaction using Android device via ADB
https://insomniac-bot.com
MIT License
695 stars 157 forks source link

add option to clear cache/data #137

Open muzzol opened 4 years ago

muzzol commented 4 years ago

this is a feature request to add an option to clear cache and data when starting the app. something like --clear-cache

I've digged a little bit and is as simple as executing this two commands:

adb shell am force-stop com.instagram.android
adb shell pm clear com.instagram.android

maybe with a sleep between them. I think they don't need root acces, but I'm not sure. maybe a prior check to see if device is rooted or not could be usefull too with something like

adb shell "su 0 id -un"

thanks for your time

alexal1 commented 4 years ago

This command doesn't require root, but it will clear all application data, including your "sign in". It means that you'll have to sign in each time again. Even if we implement "signing in" in the script, too much "sign in" requests are not good – I'm pretty sure Instagram will block them for your IP.

Why do you want to clear cache by the way?

guztavoalves commented 4 years ago

Hi, I maked this function to clean instagram cache every new session or after crash, this function remove the cache dir from instagram:

def clear_instagram_cache(device_id):
    print("[I] Clear Instagram cache")
    os.popen("adb" + ("" if device_id is None else " -s " + device_id) +
             " shell 'rm -rf /data/data/com.instagram.android/cache/*' ")
    random_sleep(3)
alexal1 commented 4 years ago

@muzzol @guztavoalves is it for memory economy on a device?

muzzol commented 4 years ago

This command doesn't require root, but it will clear all application data, including your "sign in". It means that you'll have to sign in each time again. Even if we implement "signing in" in the script, too much "sign in" requests are not good – I'm pretty sure Instagram will block them for your IP.

Why do you want to clear cache by the way?

sorry for the late response, I was busy.

I'm confused because when you get blocks the app says:

"Seems that action is blocked. Consider reinstalling Instagram app and be more careful"

reinstalling and clearing all cache/data is mostly the same, and some users report that clearing cache helps with blocks/softbans (there's a lot of comments about that in telegram group), so if this is not the case, just ignore this feature request. but it would be nice to clarify it, because I assumed it was a common thing to do when you get blocked. I'm using emulation by the way, not sure if that's relevant info.

alexal1 commented 4 years ago

Yes, that might be a good feature, but what about signing in? You have to sign in again each time you clear cache, don't you?

guztavoalves commented 4 years ago

@alexal1 Using the function above is not necessary sign in again, because this function remove the cache dir of the IG, this action have same effect of the android system > 'clear cache'

This function help devices with low memory, to not freeze Android after many sessions image

EN image

muzzol commented 4 years ago

This function help devices with low memory, to not freeze Android after many sessions

so you do it for performance reasons?

we need to clarify it because I see some people doing it to solve "action blocked" problem. (there's tons of vídeos explaining that on yt)

@alexal1 can you explain why do you suggest to reinstall the app when a block is detected?

alexal1 commented 4 years ago

@muzzol ok, I'll test this code and add it to the script if everything's ok. Thank you!

arthurspa commented 4 years ago

I think what makes the user login again is when clearing data, not cache. But I think this might slow down the runs since, i.e. the users' profile pictures would be erased and every time the bot goes back to a list of users to interact it will have to load them all again.

What about detecting when IG shows "action blocked" and only in that case we would clear the cache?

guztavoalves commented 4 years ago

About clearing the cache, I use it only for performance reasons on devices with low memory, as I already had problems with Android crashes.

And about IG blocks, it depends on the type of block you received, I know two types, soft ban and shadow ban.

Important: Whenever we receive a type of ban, the IG places our account under a bot detection system, so for approximately 48 hours our actions will be 'watched' and we can receive more blocks. The interaction limits per day also decrease. You may be asked to reset your account password.

It would be good to create a routine to deal with the soft ban:

The Loop:

  1. After an action execute detect_block();
  2. In case of soft ban, log out normally, but with notice of the block;
  3. Close the IG;
  4. Wait a few hours;
  5. Open the IG;
  6. Start a new session;
guztavoalves commented 4 years ago

Shadow Ban: image

Soft Ban: image

arthurspa commented 4 years ago

@guztavoalves , do you have the hierarchy dump for those ban messages? If yes, could you please share it? It would help developing the detect_block().

guztavoalves commented 4 years ago

Yes!

Soft Ban: Crash-2020-10-16-00-21-48.zip

Shadow Ban: shadowban_view_hierarchy.zip