Skip to content

Commit

Permalink
like users who liked me but not followed
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Okhlopkov committed Aug 29, 2019
1 parent bc7a495 commit d887655
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,27 @@ def like_media_likers(bot, media, nlikes=2):
)

my_last_medias = bot.get_your_medias()
random.shuffle(my_last_medias)
for media in my_last_medias:
my_last_media_likers = bot.get_media_likers(media)
random.shuffle(my_last_media_likers)
for user in my_last_media_likers:
user_medias = bot.get_user_medias(user)
random.shuffle(user_medias)
for m in user_medias:
like_media_likers(bot, m)
time.sleep(random.random() * 10)

my_likers = set([
liker for media in my_last_medias for liker in bot.get_media_likers(media)
])

my_followers = set(bot.followers)

likers_that_dont_follow = my_likers - my_followers
print("Found %d likers that I don't follow" % len(likers_that_dont_follow))

for user in likers_that_dont_follow:
if not bot.api.get_user_feed(user):
print("can't get %s feed, private user?" % user)

user_medias = [m["id"] for m in bot.api.last_json["items"] if not m["has_liked"]]

medias_to_like = random.sample(user_medias, min(random.randint(1,3), len(user_medias)))
for m in medias_to_like:
bot.like(m, check_media=False)
time.sleep(random.random() * 5)

time.sleep(random.random() * 10 + 5)


0 comments on commit d887655

Please sign in to comment.