docs: def _autofollow(api, action, dry_run):
      '''
      Follow back or unfollow the friends/followers of user authenicated in 'api'.
      :api twitter_bot_utils.api.API
      :dry_run bool don't actually (un)follow, just report
      '''
      try:
          # get the last 5000 followers
          followers = api.followers_ids()
  
          # Get the last 5000 people user has followed
          friends = api.friends_ids()
  
      except TweepError as e:
          api.logger.error('%s: error getting followers/followers', action)
          api.logger.error("%s", e)
          return
  
      if action == "unfollow":
          method = api.destroy_friendship
          independent, dependent = followers, friends
  
      elif action == "follow":
          method = api.create_friendship
          independent, dependent = friends, followers
      else:
          raise IndexError("Unknown action: {}".format(action))
  
      api.logger.info('%sing: found %s friends, %s followers', action, len(friends), len(followers))
  
      # auto-following:
      # for all my followers
      # if i don't already follow them: create friendship
  
      # auto-unfollowing:
      # for all my friends
      # if they don't follow me: destroy friendship
      targets = [x for x in dependent if x not in independent]
  
      for uid in targets:
          try:
              api.logger.info('%sing %s', action, uid)
  
              if not dry_run:
                  method(id=uid)
  
          except RateLimitError:
              api.logger.warning("reached Twitter's rate limit, sleeping for %d minutes", RATE_LIMIT_RESET_MINUTES)
              sleep(RATE_LIMIT_RESET_MINUTES * 60)
              method(id=uid)
  
          except TweepError as e:
              api.logger.error('error %sing on %s', action, uid)
              api.logger.error("code %s: %s", e.api_code, e)