Look for friends to drink with
197886
def looking_for_friends(self):
        ''''''
        self.info('I am looking for friends')
        available_friends = list(self.get_agents(drunk=False,
                                                 pub=None,
                                                 state_id=self.looking_for_friends.id))
        if not available_friends:
            self.info('Life sucks and I\'m alone!')
            return self.at_home
        befriended = self.try_friends(available_friends)
        if befriended:
            return self.looking_for_pub
933096
function(userObjectId) {
        if (!userObjectId || !_.isString(userObjectId)) {
          throw new Error('Invalid user object id.');
        }
        var query = new AV.FriendShipQuery('_Follower');
        query._friendshipTag = 'follower';
        query.equalTo(
          'user',
          AV.Object.createWithoutData('_User', userObjectId)
        );
        return query;
      }
757653
private function findFriendshipsByStatus($status, $limit, $offset): array
    {
        $friendships = [];

        $query = Friend::where(function ($query) use ($status) {
            $query->where('sender_id', $this->id);
            $query->where('sender_type', get_class($this));

            if (!empty($status)) {
                $query->where('status', $status);
            }
        })->orWhere(function ($query) use ($status) {
            $query->where('recipient_id', $this->id);
            $query->where('recipient_type', get_class($this));

            if (!empty($status)) {
                $query->where('status', $status);
            }
        });

        if (!empty($limit)) {
            $query->take($limit);
        }

        if (!empty($offset)) {
            $query->skip($offset);
        }

        foreach ($query->get() as $friendship) {
            $friendships[] = $this->getFriendship($this->find(
                ($friendship->sender_id == $this->id) ? $friendship->recipient_id : $friendship->sender_id
            ));
        }

        return $friendships;
    }
541291
def try_friends(self, others):
        ''' '''
        befriended = False
        k = int(10*self['openness'])
        shuffle(others)
        for friend in islice(others, k):  # random.choice >= 3.7
            if friend == self:
                continue
            if friend.befriend(self):
                self.befriend(friend, force=True)
                self.debug('Hooray! new friend: {}'.format(friend.id))
                befriended = True
            else:
                self.debug('{} does not want to be friends'.format(friend.id))
        return befriended
97834
function findUserFromToken(token, cb) {
  var q = "SELECT * FROM users " +
    "JOIN tokens t ON t.token = $1 " +
    "JOIN users u ON u.id = t.user_id";

  db.getClient(function(err, client, done) {
    client.query(q, [token], function(err, r) {
      var result = r && r.rows[0];
      if(!result && !err) { err = new exceptions.NotFound(); }
      if(err) {
        cb(err);
        done(err);
      } else {
        cb(null, result);
        done();
      }
    });
  });
}
450288
def parse_friends(self, friends_page):
    
    user_info = self.parse_sidebar(friends_page)
    second_col = friends_page.find(u'div', {u'id': u'content'}).find(u'table').find(u'tr').find_all(u'td', recursive=False)[1]

    try:
      user_info[u'friends'] = {}

      friends = second_col.find_all(u'div', {u'class': u'friendHolder'})
      if friends:
        for row in friends:
          block = row.find(u'div', {u'class': u'friendBlock'})
          cols = block.find_all(u'div')

          friend_link = cols[1].find(u'a')
          friend = self.session.user(friend_link.text)

          friend_info = {}
          if len(cols) > 2 and cols[2].text != u'':
            friend_info[u'last_active'] = utilities.parse_profile_date(cols[2].text.strip())

          if len(cols) > 3 and cols[3].text != u'':
            friend_info[u'since'] = utilities.parse_profile_date(cols[3].text.replace(u'Friends since', '').strip())
          user_info[u'friends'][friend] = friend_info
    except:
      if not self.session.suppress_parse_exceptions:
        raise

    return user_info
239447
def invited?(user)
      friendship = find_any_friendship_with(user)
      return false if friendship.nil?
      friendship.friend_id == user.id
    end
339972
def get_friends(self, limit=50, cacheable=False):
        

        seq = []
        for node in _collect_nodes(
            limit, self, self.ws_prefix + ".getFriends", cacheable
        ):
            seq.append(User(_extract(node, "name"), self.network))

        return seq
929029
def get_friends_list(self, steamID, relationship='all', format=None):
        
        parameters = {'steamid' : steamID, 'relationship' : relationship}
        if format is not None:
            parameters['format'] = format
        url = self.create_request_url(self.interface, 'GetFriendsList', 1,
            parameters)
        data = self.retrieve_request(url)
        return self.return_data(data, format=format)
285120
def get_bac(age, weight, height, sex, volume, percent):
  
  return gramm_to_promille(
    calculate_alcohol(volume, percent),
    age, weight, height, sex
  )
435991
def fetch_friends(self, user):
        

        # Fetch the token key and secret
        if USING_ALLAUTH:
            social_app = SocialApp.objects.get_current('twitter')
            consumer_key = social_app.key
            consumer_secret = social_app.secret

            oauth_token = SocialToken.objects.get(account=user, app=social_app).token
            oauth_token_secret = SocialToken.objects.get(account=user, app=social_app).token_secret
        else:
            t = TwitterBackend()
            tokens = t.tokens(user)
            oauth_token_secret = tokens['oauth_token_secret']
            oauth_token = tokens['oauth_token']

            # Consumer key and secret from settings
            consumer_key = settings.TWITTER_CONSUMER_KEY
            consumer_secret = settings.TWITTER_CONSUMER_SECRET

        # now fetch the twitter friends using `python-twitter`
        api = twitter.Api(
            consumer_key=consumer_key,
            consumer_secret=consumer_secret,
            access_token_key=oauth_token,
            access_token_secret=oauth_token_secret
        )
        return api.GetFriends()
18280
def fetch_social_friend_ids(self, social_auth_user):
        

        # Type check
        self.assert_user_is_social_auth_user(social_auth_user)

        # Get friend finder backend
        friends_provider = SocialFriendsFinderBackendFactory.get_backend(social_auth_user.provider)

        # Get friend ids
        friend_ids = friends_provider.fetch_friend_ids(social_auth_user)

        return friend_ids
1170015
def individuals(self, ind_ids=None):
        """"""
        query = self.query(Individual)
        if ind_ids:
            query = query.filter(Individual.ind_id.in_(ind_ids))
        return query
883289
def friends(self):
        
        if self._friends is None:
            self.assert_bind_client()
            if self.friend_count > 0:
                self._friends = self.bind_client.get_athlete_friends(self.id)
            else:
                # Shortcut if we know there aren't any
                self._friends = []
        return self._friends
12805
def get_friends(self):
        """"""
        for k, v in iter(self.user_data.language_data.items()):
            data = []
            for friend in v['points_ranking_data']:
                temp = {'username': friend['username'],
                        'id': friend['id'],
                        'points': friend['points_data']['total'],
                        'languages': [i['language_string'] for i in
                                      friend['points_data']['languages']]}
                data.append(temp)

            return data
1160766
def find_any_friendship_with(user)
      friendship = Amistad.friendship_class.where(:friendable_id => self.id, :friend_id => user.id).first
      if friendship.nil?
        friendship = Amistad.friendship_class.where(:friendable_id => user.id, :friend_id => self.id).first
      end
      friendship
    end
464155
def get_friends(self, query):
        
        # Connecting to the API
        api = self._connectToAPI()

        # Verifying the limits of the API
        self._rate_limit_status(api=api, mode="get_friends")

        # Making the call to the API
        try:
            friends_ids = api.friends_ids(query)
        except:
            return []

        """res = []
        # Extracting the information from each profile
        for a in aux:
            us= self.getUser(a)
            res.append(self._processUser(us))"""

        return friends_ids