Open sell opened 3 years ago
Can you please take a look at it, and maybe add it as a template or you can critique and improve it.
This really depends on the account you're doing this with.
Just to note: In the inapp followers-page, you can select accounts you don't follow back
, however it's not supported in this library.
const followers = [
...await followersFeed.items(),
...await followersFeed.items(),
]
const following = [
...await followingFeed.items(),
...await followingFeed.items(),
]
Don't do this. This is only possible if you know how many followers the account has. You should use a function. It can be generic over the item of a feed. Here is an example (Comment).
notFollowingYou.forEach((user) => {
ig.friendship.destroy(user.pk);
console.log(`unfollowed ${user.username}`)
});
This code works but it will probably break if there are too many users,
await
for (const user of notFollowingYou) {
await ig.friendship.destroy(user.pk);
console.log(`unfollowed ${user.username}`)
}
Thanks for the feedback, so in my original one I had a random delay between 3 and 10 seconds. I should of used a for-each loop, don't know why I didn't use it here, maybe because I was rushing.
Also, you're right should of used a try/catch as I am dealing with await here.
Thanks for the response and actually taking your time to write all of this, will make the neccesary changes. I assume, I don't need to update the code as others can just see your comment and make the changes themselves.
@Nerixyz, made necessary changes. Here is a gist: https://gist.github.com/sell/be175dcd85954f41af94858ca231a3b4
Let me know, if this is much better.
const followers = await getAllItemsFromFeed(followersFeed)
is pretty obvious on what it does. It gets all items from the followers-feed. And as the variable-name suggests, the items are followers - no comment needed. sleep
function. This makes it descriptive (and self-documenting).getAllItemsFromFeed
and arrow-function. It should stay as a regular function thus it will always be accessible (as it's hoisted).import
and annotate the getAllItemsFromFeed
function with generics. (I didn't so that in my thing)Maybe instead of importing util, maybe we can just do this?
const time = Math.round(Math.random() * (6000)) + 1000;
await new Promise((resolve) => setTimeout(resolve, time));
Just saves a few lines of code. Thanks for critiquing again, shall I make it into ts or will you do so?
Edit: Also, nice package you guys made.
Maybe instead of importing util, maybe we can just do this?
Yeah it's essentially the same.
Thanks for critiquing again, shall I make it into ts or will you do so?
Feel free to open a PR.
Feel free to open a PR.
PR Submitted
General Question
Form
Put an
[x]
if you meet the condition, else leave[ ]
.Question
Hello, i have wrote a little code to unfollow users who aren't following you. Can you please take a look at it, and maybe add it as a template or you can critique and improve it.
Code
A meaningful section of your code (else delete this). If you are using TypeScript replace
js
withtypescript
.