ohld / igbot

🐙 Free scripts, bots and Python API wrapper. Get free followers with our auto like, auto follow and other scripts!
https://hikerapi.com/p/N2P6iqiM
Apache License 2.0
4.72k stars 1.47k forks source link

I found a few errors from closed #625 PR #659

Closed ademaro closed 5 years ago

ademaro commented 6 years ago

Please follow the guide below


Before submitting an issue, make sure you have:

Purpose of your issue?


For a bug report, you must include the Python version used, code that will reproduce the error, and the error log/traceback.

Paste the output of python -V here: Python 3.7.0

Code:

# Example code that will produce the error reported
from instabot import Bot

bot = Bot()
bot.login(username="user", password="pass")
bot.like_user('_insert_user_id_here_', amount=3)

Error/Debug Log:

Traceback (most recent call last):
  File "test_like.py", line 49, in <module>
    like_users(bot)
  File "test_like.py", line 29, in like_users
    bot.like_user(user_id, amount=3)
  File "/Users/anton/GitHub/instabot/instabot/bot/bot.py", line 426, in like_user
    return like_user(self, user_id, amount, filtration)
  File "/Users/anton/GitHub/instabot/instabot/bot/bot_like.py", line 68, in like_user
    if not self.check_user(user_id, filter_closed_acc=True):
TypeError: check_user() got an unexpected keyword argument 'filter_closed_acc'

and

Traceback (most recent call last):
  File "test_like.py", line 49, in <module>
    like_users(bot)
  File "test_like.py", line 29, in like_users
    bot.like_user(user_id, amount=3)
  File "/Users/anton/GitHub/instabot/instabot/bot/bot.py", line 426, in like_user
    return like_user(self, user_id, amount, filtration)
  File "/Users/anton/GitHub/instabot/instabot/bot/bot_like.py", line 77, in like_user
    return self.like_medias(medias[:amount])
  File "/Users/anton/GitHub/instabot/instabot/bot/bot.py", line 417, in like_medias
    return like_medias(self, media_ids)
  File "/Users/anton/GitHub/instabot/instabot/bot/bot_like.py", line 52, in like_medias
    if not self.like(media):
  File "/Users/anton/GitHub/instabot/instabot/bot/bot.py", line 411, in like
    return like(self, media_id)
  File "/Users/anton/GitHub/instabot/instabot/bot/bot_like.py", line 7, in like
    if not self.check_media(media_id):
  File "/Users/anton/GitHub/instabot/instabot/bot/bot.py", line 598, in check_media
    return check_media(self, media)
  File "/Users/anton/GitHub/instabot/instabot/bot/bot_filter.py", line 62, in check_media
    if search_blacklist_hashtags_in_media(self, media_id):
  File "/Users/anton/GitHub/instabot/instabot/bot/bot_filter.py", line 98, in search_blacklist_hashtags_in_media
    text = self.get_media_info(media_id)[0]['caption']['text']
TypeError: 'NoneType' object is not subscriptable

Describe your issue

@ohld @basnijholt Guys, when you accepted the #625, liking ceased to work... @Olcaey forgot to correct the lines in the files:

diff --git a/bot/bot_comment.py b/bot/bot_comment.py
index 98fc329..00c94ac 100644
--- a/bot/bot_comment.py
+++ b/bot/bot_comment.py
@@ -49,7 +49,7 @@ def comment_hashtag(self, hashtag, amount=None):

 def comment_user(self, user_id, amount=None):
     """ Comments last user_id's medias """
diff --git a/bot/bot_comment.py b/bot/bot_comment.py
index 98fc329..00c94ac 100644
--- a/bot/bot_comment.py
+++ b/bot/bot_comment.py
@@ -49,7 +49,7 @@ def comment_hashtag(self, hashtag, amount=None):

 def comment_user(self, user_id, amount=None):
     """ Comments last user_id's medias """
-    if not self.check_user(user_id, filter_closed_acc=True):
+    if not self.check_user(user_id):
         return False
     self.logger.info("Going to comment user_%s's feed:" % user_id)
     user_id = self.convert_to_user_id(user_id)
diff --git a/bot/bot_filter.py b/bot/bot_filter.py
index c44d585..d3f6b51 100755
--- a/bot/bot_filter.py
+++ b/bot/bot_filter.py
@@ -95,7 +95,8 @@ def search_stop_words_in_user(self, user_info):

 def search_blacklist_hashtags_in_media(self, media_id):
-    text = self.get_media_info(media_id)[0]['caption']['text']
+    media = self.get_media_info(media_id)[0]
+    text = media['caption']['text'] if media['caption'] else ''

     comments_number = max(6, len(self.get_media_comments(media_id)))
     text += ''.join(self.get_media_comments(media_id, only_text=True)[:comments_number])
diff --git a/bot/bot_like.py b/bot/bot_like.py
index 6949b29..c99a58e 100755
--- a/bot/bot_like.py
+++ b/bot/bot_like.py
@@ -65,7 +65,7 @@ def like_timeline(self, amount=None):
Olcaey commented 6 years ago

Hi, I tried to fix the filter_closed_acc and search_blacklist_hashtags_in_media. Anything else that you could observe?

It seems somehow mine didn't have these errors and I didn't realize. Sorry for this.

ademaro commented 6 years ago

@Olcaey The rest seems to be good, I'm testing further. It would be cool to cover the code with unit test.

ohld commented 6 years ago

@Olcaey @ademaro Can someone please enhance the current test coverage to cover that changes?

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.