修改昵称
@param $username
@param $nickname
@return bool
179704
function set_nickname($username , $nickname){
        if(empty($nickname) || empty($username)){
            return false;
        }
        $token = $this->get_token();
        $header = array('Authorization: Bearer '.$token);
        $path = 'users/'.$username;
        $request_body = array("nickname"=>$nickname);
        $result = $this->api_request($path, json_encode($request_body,JSON_UNESCAPED_UNICODE) , 'PUT', $header);
        return $this->result_handler($result);
    }
1205411
public function isFounder($channel, $nickname = null)
    {
        if (!$this->_channelsyncing) {
            $this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: isFounder() is called '
                .'and the required Channel Syncing is not activated!',
                __FILE__, __LINE__
            );
            return false;
        }

        if ($nickname === null) {
            $nickname = $this->_nick;
        }

        return ($this->isJoined($channel, $nickname)
            && $this->getUser($channel, $nickname)->founder
        );
    }
1050020
public function validateAccountConfirmationToken($username, $token)
    {
        $this->username = $username;

        if ($this->getMeta()->confirmationToken == $token) {
            $this->getMeta()->confirmed = true;
            $this->getMeta()->confirmationToken = '';
            $this->getMeta()->save();

            return true;
        }

        return false;
    }
188528
public static function userHasRole($role , $username = null)
	{
		if ( is_null( $username ) ) $username = self::getCurrentUsername();
		if ( is_null( $username ) ) return false;
		if ( ! self::userExists( $username ) ) return false;
		if ( in_array( 'admin' , self::$auth['users'][ $username ]['roles'] ) ) return true;
		return ( in_array( $role , self::$auth['users'][ $username ]['roles'] ) );
	}
782989
static function muc($to, $nickname = false, $mam = false)
    {
        $session = Session::start();

        $dom = new \DOMDocument('1.0', 'UTF-8');
        $presence = $dom->createElementNS('jabber:client', 'presence');
        $dom->appendChild($presence);

        $presence->setAttribute('from', $session->get('username').'@'.$session->get('host').'/'.$session->get('resource'));
        $presence->setAttribute('id', $session->get('id'));
        $presence->setAttribute('to', $to.'/'.$nickname);

        $x = $dom->createElementNS('http://jabber.org/protocol/muc', 'x');

        if($mam) {
            $history = $dom->createElement('history');
            $history->setAttribute('maxchars', 0);
            $x->appendChild($history);
        }

        $presence->appendChild($x);

        \Moxl\API::request($dom->saveXML($dom->documentElement));
    }
369519
public function removeOrganizationMembership(string $org, string $username): bool
    {
        $this->getApi()->setAccept('application/vnd.github.moondragon+json');

        $this->getApi()->request($this->getApi()->sprintf('/orgs/:org/memberships/:username', $org, $username),
            Request::METHOD_DELETE);

        if ($this->getApi()->getHeaders()['Status'] == '204 No Content') {
            return true;
        }

        return false;
    }
821636
public function create(string $account, string $nickname)
    {
        $params = [
            'kf_account' => $account,
            'nickname' => $nickname,
        ];

        return $this->httpPostJson('customservice/kfaccount/add', $params);
    }
1338689
public function login(string $username, string $password)
    {
        $this->userInfo = $this->makeRequest('POST', 'login', compact('username', 'password'));

        if (!isset($this->userInfo['error']) && isset($this->userInfo['data']['id'])) {
            return true;
        }

        return false;
    }
286197
public function publicizeUsersMembership(string $org, string $username): bool
    {
        $this->getApi()->request($this->getApi()->sprintf('/orgs/:org/public_members/:username', $org, $username),
            Request::METHOD_PUT);

        if ($this->getApi()->getHeaders()['Status'] == '204 No Content') {
            return true;
        }

        return false;
    }
652669
public static function userExists($username)
	{
		if ( ! is_array( self::$auth ) ) throw new Exception( 'Authentication not initialized' );
		return ( isset( self::$auth['users'][ $username ] ) );
	}
467746
public function setUsername($id, $username)
    {
        return $this->put($this->getPath().'/'.rawurlencode($id).'/username', array('value' => $username));
    }
335496
public function checkUser($username = null)
  {
    if($username === null)
    {
      $username = $this->user;
    }

    if(strlen($username) == 0)
    {
      return TRUE;
    }

    $pattern = "/^(" . $this->regex["alphanum"]  . "|" . $this->regex["mark"] . "|" . $this->regex["escaped"] . "|[;:&=+$,])+$/";
    $status = @preg_match($pattern, $username);

    if($status === FALSE)
    {
      throw new TeamSpeak3_Helper_Exception("URI username validation failed");
    }

    return ($status == 1);
  }
1243338
public function update(string $account, string $nickname)
    {
        $params = [
            'kf_account' => $account,
            'nickname' => $nickname,
        ];

        return $this->httpPostJson('customservice/kfaccount/update', $params);
    }
633053
public function getByUsername($username)
    {
        if (!is_string($username)) {
            return false;
        }

        $data = [
            'where' => [
                [
                    'column' => $this->tableAlias . '.username',
                    'value'  => $username,
                ],
            ],
        ];

        $user = $this->getAll(null, null, $data);

        return empty($user) ? false : $user[0];
    }
179712
public function ircWhowas($nickname, $count = null, $server = null)
    {
        $this->queueIrcRequest('WHOWAS', [ $nickname, $count, $server ]);
    }
1193253
final public static function createOtpToken (string $username)
	{
		$token = self::setOtpToken();
		return self::setUserOtpToken($username, $token);
	}
172891
public function isJoined($channel, $nickname = null)
    {
        if (!$this->_channelsyncing) {
            $this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: isJoined() is called '
                .'and the required Channel Syncing is not activated!',
                __FILE__, __LINE__
            );
            return false;
        }

        if (!isset($this->_channels[strtolower($channel)])) {
            if ($nickname !== null) {
                $this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: isJoined() is called'
                    .' on a user in a channel we are not joined to!',
                    __FILE__, __LINE__
                );
            }
            return false;
        }

        if ($nickname === null) {
            return true;
        }

        return isset($this->getChannel($channel)->users[strtolower($nickname)]);
    }