Skip to content

Commit

Permalink
• Fix ignoring --follow-limit when following private/empty accounts
Browse files Browse the repository at this point in the history
• Fix crash when trying to follow a user who's already "Requested"
  • Loading branch information
Alexander Mishchenko committed Oct 10, 2020
1 parent c8286c6 commit be095aa
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions src/action_handle_blogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
FOLLOWERS_BUTTON_ID_REGEX = 'com.instagram.android:id/row_profile_header_followers_container' \
'|com.instagram.android:id/row_profile_header_container_followers'
TEXTVIEW_OR_BUTTON_REGEX = 'android.widget.TextView|android.widget.Button'
FOLLOW_REGEX = 'Follow|Follow Back'
UNFOLLOW_REGEX = 'Following|Requested'


def handle_blogger(device,
Expand Down Expand Up @@ -224,10 +226,12 @@ def _interact_with_user(device,
recycler_view = device.find(resourceId='android:id/list')
if not recycler_view.exists():
print(COLOR_OKGREEN + "Private / empty account." + COLOR_ENDC)
followed = _follow(device,
username,
follow_percentage) if profile_filter.can_follow_private_or_empty() else False
if not followed:
if can_follow and profile_filter.can_follow_private_or_empty():
followed = _follow(device,
username,
follow_percentage)
else:
followed = False
print(COLOR_OKGREEN + "Skip user." + COLOR_ENDC)
return False, followed

Expand Down Expand Up @@ -320,22 +324,24 @@ def _follow(device, username, follow_percentage):

random_sleep()

follow_button = device.find(classNameMatches=TEXTVIEW_OR_BUTTON_REGEX,
clickable=True,
text='Follow')
if not follow_button.exists():
follow_button = device.find(classNameMatches=TEXTVIEW_OR_BUTTON_REGEX,
clickable=True,
text='Follow Back')
profile_header_actions_layout = device.find(resourceId='com.instagram.android:id/profile_header_actions_top_row',
className='android.widget.LinearLayout')
if not profile_header_actions_layout.exists():
print(COLOR_FAIL + "Cannot find profile actions." + COLOR_ENDC)
return False

follow_button = profile_header_actions_layout.child(classNameMatches=TEXTVIEW_OR_BUTTON_REGEX,
clickable=True,
textMatches=FOLLOW_REGEX)
if not follow_button.exists():
unfollow_button = device.find(classNameMatches=TEXTVIEW_OR_BUTTON_REGEX,
clickable=True,
text='Following')
unfollow_button = profile_header_actions_layout.child(classNameMatches=TEXTVIEW_OR_BUTTON_REGEX,
clickable=True,
textMatches=UNFOLLOW_REGEX)
if unfollow_button.exists():
print(COLOR_OKGREEN + "You already follow @" + username + "." + COLOR_ENDC)
return False
else:
print(COLOR_FAIL + "Cannot find neither Follow button, nor Following button. Maybe not "
print(COLOR_FAIL + "Cannot find neither Follow button, nor Unfollow button. Maybe not "
"English language is set?" + COLOR_ENDC)
save_crash(device)
switch_to_english(device)
Expand Down

0 comments on commit be095aa

Please sign in to comment.