def open_user_followers(self, device, username): if username is None: logger.info("Open your followers") profile_view = TabBarView(device).navigateToProfile() profile_view.navigateToFollowers() else: search_view = TabBarView(device).navigateToSearch() profile_view = search_view.navigateToUsername(username) random_sleep() if not profile_view: return False logger.info(f"Open @{username} followers") profile_view.navigateToFollowers() return True
def handle_username_file( self, device, current_file, likes_count, stories_count, stories_percentage, follow_percentage, follow_limit, current_job, storage, profile_filter, on_like, on_watch, on_interaction, ): interaction = partial( interact_with_user, my_username=self.session_state.my_username, likes_count=likes_count, stories_count=stories_count, stories_percentage=stories_percentage, follow_percentage=follow_percentage, on_like=on_like, on_watch=on_watch, profile_filter=profile_filter, args=self.args, session_state=self.session_state, current_mode=self.current_mode, ) is_follow_limit_reached = partial( is_follow_limit_reached_for_source, follow_limit=follow_limit, source=current_file, session_state=self.session_state, ) need_to_refresh = True if path.isfile(current_file): with open(current_file, "r") as f: for line in f: username = line.strip() if username != "": if storage.is_user_in_blacklist(username): logger.info(f"@{username} is in blacklist. Skip.") continue elif storage.check_user_was_interacted(username): logger.info( f"@{username}: already interacted. Skip.") continue if need_to_refresh: search_view = TabBarView(device).navigateToSearch() random_sleep() profile_view = search_view.navigateToUsername( username, True, need_to_refresh) need_to_refresh = False if not profile_view: continue random_sleep() def interact(): can_follow = not is_follow_limit_reached() and ( storage.get_following_status(username) == FollowingStatus.NONE or storage.get_following_status(username) == FollowingStatus.NOT_IN_LIST) interaction_succeed, followed = interaction( device, username=username, can_follow=can_follow) storage.add_interacted_user(username, followed=followed) can_continue = on_interaction( succeed=interaction_succeed, followed=followed) if not can_continue: return False else: return True logger.info(f"@{username}: interact") if not interact(): break device.back() else: logger.info("Line in file is blank, skip.") remaining = f.readlines() if self.args.delete_interacted_users: with open(current_file, "w") as f: f.writelines(remaining) else: logger.warning(f"File {current_file} not found.") return logger.info(f"Interact with users in {current_file} complete.") device.back()