Return User object for a given Slack ID or name
507552
def user(self, match):
        
        if len(match) == 9 and match[0] == 'U':
            return self._lookup(User, 'id', match)
        return self._lookup(User, 'name', match)
562260
def get_owner_names_value(self, obj):
        """"""
        return [
            self._get_user(user)
            for user in get_users_with_permission(obj, get_full_perm('owner', obj))
        ]
141770
def post(options)
      payload = {
        username: @options['name'],
        channel:  @options['channel']
      }.merge(options)
      payload[:channel] = payload[:channel].gsub(/^#?/, '#') #slack api needs leading # on channel
      request = Net::HTTP::Post.new(@uri.request_uri)
      request.set_form_data(payload: payload.to_json)
      @http.request(request)
      return nil # so as not to trigger text in outgoing webhook reply
    end
107164
def getUser(self):
        
        username = self.getUsername()
        if not username:
            return None
        user = api.user.get(userid=username)
        return user
1010959
def get_user(user_or_username=None):
    
    if user_or_username is None:
        return None
    if hasattr(user_or_username, "getUserId"):
        return ploneapi.user.get(user_or_username.getUserId())
    return ploneapi.user.get(userid=u.to_string(user_or_username))
565965
def _get_user(self, username):
        
        if username is None:
            return {}
        ret = {}
        for b in self.backends:
            try:
                tmp = self.backends[b].get_user(username)
            except UserDoesntExist as e:
                self._handle_exception(e)
                tmp = {}
            self._merge_user_attrs(tmp, ret, b)

        cherrypy.log.error(
            msg="user '" + username + "' attributes " + str(ret),
            severity=logging.DEBUG
        )
        return ret
221733
def get_user_data_iobject(user=None,group=None,data_kind=DINGOS_USER_DATA_TYPE_NAME):
        
        logger.debug("Get user settings called")

        if not user.is_authenticated():
            user = None
        try:
            user_config =  UserData.objects.get(user=user,group=group,data_kind=data_kind)
            return user_config.identifier.latest
        except:
            return None
452917
def load_user(self, uid):
    
        '''
            
        '''
    
        title = '%s.load_user' % self.__class__.__name__
        
    # validate inputs
        input_fields = {
            'uid': uid
        }
        for key, value in input_fields.items():
            if value:
                object_title = '%s(%s=%s)' % (title, key, str(value))
                self.fields.validate(value, '.%s' % key, object_title)
    
    # construct url
        url = self.bucket_url + '/_user/%s' % uid
        
    # send request and unwrap response
        response = requests.get(url)
        response = response.json()
    
        return response
477833
def get_user_by_id(uid,**kwargs):
    
    user_id = kwargs.get('user_id')
    try:
        user_i = _get_user(uid)
        return user_i
    except NoResultFound:
        return None
400222
def get_user_display_name(self, userid):
        '''
        '''

        user_info = self.slack_client.api_call('users.info', user=userid)
        if user_info.get('ok'):
            user = user_info.get('user')
            if user.get('profile'):
                return user.get('profile').get('display_name')
            else:
                return user.get('name')
        else:
            return userid
474881
def im_open(self, *, user: str, **kwargs) -> SlackResponse:
        
        kwargs.update({"user": user})
        return self.api_call("im.open", json=kwargs)
291610
def kick(self, group_name, user):
        
        group_id = self.get_group_id(group_name)
        self.params.update({
            'channel': group_id,
            'user':    user,
            })
        return FromUrl('https://slack.com/api/groups.kick', self._requests)(data=self.params).post()
1309092
def get_user(self, name):
        
        return self._api_get('/api/users/{0}'.format(
            urllib.parse.quote_plus(name)
        ))
201861
def channel_to_id(slack, channel):
    
    channels = slack.api_call('channels.list').get('channels') or []
    groups = slack.api_call('groups.list').get('groups') or []

    if not channels and not groups:
        raise RuntimeError("Couldn't get channels and groups.")

    ids = [c['id'] for c in channels + groups if c['name'] == channel]

    if not ids:
        raise ValueError(f"Couldn't find #{channel}")

    return ids[0]
399450
def get_user(self, user_id=None):
        
        if user_id:
            return self.get('/users/{0}/'.format(user_id))
        return self.get('/users/me/')
182993
def get_slack_channels(self, token):
        '''
        
        '''

        ret = salt.utils.slack.query(
            function='rooms',
            api_key=token,
            # These won't be honored until https://github.com/saltstack/salt/pull/41187/files is merged
            opts={
                'exclude_archived': True,
                'exclude_members': True
            })
        channels = {}
        if 'message' in ret:
            for item in ret['message']:
                channels[item['id']] = item['name']
        return channels
570916
def user(session, uid, ladder_ids=None):
    """"""
    data = get_user(session, uid)
    resp = dict(data)
    if not ladder_ids:
        return resp
    resp['ladders'] = {}
    for ladder_id in ladder_ids:
        if isinstance(ladder_id, str):
            ladder_id = lookup_ladder_id(ladder_id)
        try:
            ladder_data = dict(get_ladder(session, ladder_id, user_id=uid))
            resp['ladders'][ladder_id] = ladder_data
        except VooblyError:
            # No ranking on ladder
            pass
    return resp