def need_unfollow(api, user): """Check if a user need to be unfollowed """ statuses_count = user.statuses_count followers_count = user.followers_count friends_count = user.friends_count is_followed = is_followed_by(api, target_screen_name=user.screen_name) if not is_followed: return True
def main(): api = setup_api(consumer_key, consumer_secret, access_key, access_secret) file_path = "tweets.txt" tweet_data = read_list(file_path) tweet_text = pick_random_element(tweet_data) # get target target_accounts = api.friends() done = False while not done: target_account = pick_random_element(target_accounts) is_followed = is_followed_by(api, target_screen_name=target_account.screen_name) if is_good_account(target_account) and not is_followed: reply(api, tweet_text, target_account) done = True