mifi / instauto

Instagram bot / automation library written in Javascript for Node.js
799 stars 145 forks source link

Follow Users Who Liked Content Of User #85

Open Flamintus opened 2 years ago

Flamintus commented 2 years ago

Based on #75 may you provide a way to list content_shortcodes from a user, so we get an input for the function getUsersWhoLikedContent({ contentId })

Awaited workflow for FollowUsersWhoLikedContentOfUser :

Please notice that if I use FollowUsersWhoLikedContentFromThisUser on My account it will auto follow users who liked my posts

Flamintus commented 2 years ago

Indeed I'm talking here about an "enhancement" :) Because this code run perfectly! Thanks by advance 👍

Flamintus commented 2 years ago

@joelemanoel maybe you already have something like that!? :)

joelemanoel commented 2 years ago

Yeah. I will develop soon. Just find some free time and I'll do it.

Flamintus commented 2 years ago

@joelemanoel Thank you very much by advance. I'm really enthusiast about this project, if I can help, let me know I will! Already started with the 2 first PR of my life today :))

Flamintus commented 2 years ago

Quick Share, for the moment, I run with that 👍

`
console.log('### PART 2 :STARTING following liker of my posts');

console.log('Searching for liker of my posts');

const myposts = ['CbuV2QhAdyN','CbwxgsyAcgc','CbtAGqjATiz','Cbs6nSTAqud','Cbs4pj8AdBb','Cbs3egsgh_K','CbsqCV6ASfj','CbsgS_LAsHn','CbdcPixvoZG','Cbv5JxtAM9'];

for await (const post of myposts) {

    const getUsersWhoLikedContent= await instauto.getUsersWhoLikedContent({ contentId: post, maxPages: 10 }); console.log(getUsersWhoLikedContent);

    for await (const userstofollow of getUsersWhoLikedContent) 
    {
        console.log('users to like ?', userstofollow)

       for await (const usertofollow of userstofollow) {

            console.log('usertolike', usertofollow)
            console.log('Following');
            await instauto.followUser(usertofollow);

        }
    }
}
console.log('DONE following liker of my posts');`

Unfortunately, I dont have enough skill in NODEJS to :

metapodcod commented 2 years ago

is there any progress on this?

Flamintus commented 2 years ago

I can share my actual peace of code that is working. BUT I'm pretty sure that it is a bad way to do it, @joelemanoel may you help to integrate it properly ?

    logger.info('####################################################');
    logger.info('### PART 1 :STARTING following liker of my posts ###');
    logger.info('####################################################');
    logger.info('### Searching for liker of my posts');
    const myposts = ['POSTID', 'POSTID', 'POSTID', 'POSTID'];
    logger.info('Post list : ', myposts);

    // END TODO

    // Lister mes Followers
    logger.info('### Searching for all previously folowed users');
    const allFollowing = await instauto.listManuallyFollowedUsers();
    logger.info('allFollowing', allFollowing);

    // On boucle sur les posts
    logger.info('### Starting Loop on my posts');
    for await (const post of myposts) {

        logger.info('####################################################');
        logger.info('### Searching for likers of postid ', post);
        logger.info('####################################################');
        const getUsersWhoLikedContent= await instauto.getUsersWhoLikedContent({ contentId: post, maxPages:10});  console.log(getUsersWhoLikedContent);

        // On boucle sur les flollowers du post
        for await (const userstofollow of getUsersWhoLikedContent) {

            logger.info('### Loop on Users', userstofollow)

            for await (const usertofollow of userstofollow) {

                await instauto.throttle();

                logger.info('####################################################');
                logger.info('### New USER', usertofollow);
                logger.info('####################################################');

                logger.info('[',usertofollow,']','Analysing');

                // EN COURS Si pas déja suivi
                logger.info('[',usertofollow,']','[CHECK][Recently Asked for follow] Runing');
                const allreadyaskedforfollow = await instauto.haveRecentlyFollowedUser(usertofollow);
                logger.info('[',usertofollow,']','[CHECK][Recently Asked for follow] Result', allreadyaskedforfollow);

                logger.info('[',usertofollow,']','[CHECK][Allready Folloing] Runing');
                const allreadyfollowed = allFollowing.find(allFollowing => {
                  return allFollowing === usertofollow
                })
                logger.info('[',usertofollow,']','[CHECK][Allready Folloing] Result', !!allreadyfollowed);

                if (allreadyfollowed) {
                    logger.info('[',usertofollow,']','----> SKIP (We are Allready Folloing this user)');
                }else if(allreadyaskedforfollow){
                    logger.info('[',usertofollow,']','----> SKIP (We Recently Asked this user for follow)');
                }else{
                    logger.info('[',usertofollow,']','[CONTINUE][Not folowing and not recently followed by me]');

                    // Todo Si non privé
                    logger.info('[',usertofollow,']','[CHECK][Does User Flow me] Runing');
                    const followsMe = await instauto.doesUserFollowMe(usertofollow);
                    logger.info('[',usertofollow,']','[CHECK][Does User Flow me] Result', followsMe);

                    if(followsMe != true){
                        logger.info('[FINISHED] Following user ', usertofollow);
                        logger.info('[',usertofollow,']','[FINISH][Following user] Runing');

                        await instauto.followUser(usertofollow);
                        logger.info('[FINISH][Following user] DONE', usertofollow);
                        logger.info('[',usertofollow,']','[FINISH][Following user] DONE');

                    }else{
                        logger.info('[',usertofollow,']','----> SKIP (We are allready followed by this user)');
                    }
                }
            }
        }
    }
    console.log('DONE following liker of my posts');

Also you have to edit .\node_modules\instauto\src\index.js to add this in the global return function

    doesUserFollowMe,
    navigateToUserAndGetData,
    throttle,
    haveRecentlyFollowedUser,

image

Flamintus commented 1 year ago

Any news about this ?