Skip to content
Permalink
Browse files

Bot stops working if like action is banned (#2542)

  • Loading branch information
nickgryg committed Feb 12, 2020
1 parent a10d588 commit a72642a4d9c529506ed7f208a96a0fce72423948
Showing with 12 additions and 3 deletions.
  1. +2 −1 Releases.md
  2. +1 −1 instabot_py/__init__.py
  3. +9 −1 instabot_py/instabot.py
@@ -2,4 +2,5 @@
|:-------:|:---------------------------------------------------|
| 0.5.21 | Verify configuration before start a bot |
| 0.5.22 | Stop instabot if we have nonexistent tag in config |
| 0.5.23 | Fixed a bug: `like_followers_per_run` functionality didn't work |
| 0.5.23 | Fixed a bug: `like_followers_per_run` functionality didn't work |
| 0.5.24 | Bot stops working if like action is banned. Bot can be started again with `like_per_run: 0` configuration setting |
@@ -1,4 +1,4 @@
from .instabot import InstaBot

__all__ = ['InstaBot']
__version__ = '0.5.23'
__version__ = '0.5.24'
@@ -648,6 +648,15 @@ def like(self, media_id, media_url):
if resp.status_code == 200:
self.persistence.insert_media(media_id=media_id, status="200")
return True
elif resp.status_code == 400:
self.logger.info(f"Could not like media: id: {media_id}, url: "
f"{media_url}, status code: {resp.status_code}. "
f"Reason: {resp.text}")
self.logger.fatal("Your like action has just been banned by "
"Instagram. Exiting from a program... You can "
"start your bot again if you disable like action "
"in your configuration: set 'like_per_run: 0'")
exit(0)
else:
self.persistence.insert_media(media_id=media_id,
status=str(resp.status_code))
@@ -656,7 +665,6 @@ def like(self, media_id, media_url):
f"status code: {resp.status_code}. "
f"Reason: {resp.text}")
return False
return True

def unlike(self, media_id):
""" Send http request to unlike media by ID """

0 comments on commit a72642a

Please sign in to comment.
You can’t perform that action at this time.