public function onMode(Event $event)
    {
        $msg = $event->getMessage();
        $params = $msg['params'];

        $isValidMessage =
            isset($params['channel'], $params['params']) &&
            preg_match('/(?:\+|-)[hovaq+-]+/i', $params['mode'])
        ;

        if (!$isValidMessage) {
            return;
        }

        $chan = $params['channel'];
        $nicks = explode(' ', $params['params']);
        $modes = str_split($params['mode'], 1);

        $operation = array_shift($modes); // + or -
        while ($char = array_shift($modes)) {
            $nick = array_shift($nicks);
            $mode = self::$modesNum[$char];

            $userMode = $this->storage->getUserMode($nick, $chan);
            if (!$userMode) {
                $userMode = self::REGULAR;
            }

            switch ($operation) {
                case '+':
                    $userMode |= $mode;
                    break;
                case '-':
                    $userMode ^= $mode;
                    break;
            }

            $this->storage->setUserMode($nick, $chan, $userMode);
        }
    }
public function onMode(Event $event)
    {
        $msg = $event->getMessage();
        $params = $msg['params'];

        $isValidMessage =
            isset($params['channel'], $params['params']) &&
            preg_match('/(?:\+|-)[hovaq+-]+/i', $params['mode'])
        ;

        if (!$isValidMessage) {
            return;
        }

        $chan = $params['channel'];
        $nicks = explode(' ', $params['params']);
        $modes = str_split($params['mode'], 1);

        $operation = array_shift($modes); // + or -
        while ($char = array_shift($modes)) {
            $nick = array_shift($nicks);
            $mode = self::$modesNum[$char];

            $userMode = $this->storage->getUserMode($nick, $chan);
            if (!$userMode) {
                $userMode = self::REGULAR;
            }

            switch ($operation) {
                case '+':
                    $userMode |= $mode;
                    break;
                case '-':
                    $userMode ^= $mode;
                    break;
            }

            $this->storage->setUserMode($nick, $chan, $userMode);
        }
    }
public function onMode ( Event $ event ) { $ msg = $ event -> getMessage ( ) ; $ params = $ msg [ 'params' ] ; $ isValidMessage = isset ( $ params [ 'channel' ] , $ params [ 'params' ] ) && preg_match ( '/(?:\+|-)[hovaq+-]+/i' , $ params [ 'mode' ] ) ; if ( ! $ isValidMessage ) { return ; } $ chan = $ params [ 'channel' ] ; $ nicks = explode ( ' ' , $ params [ 'params' ] ) ; $ modes = str_split ( $ params [ 'mode' ] , 1 ) ; $ operation = array_shift ( $ modes ) ; // + or - while ( $ char = array_shift ( $ modes ) ) { $ nick = array_shift ( $ nicks ) ; $ mode = self :: $ modesNum [ $ char ] ; $ userMode = $ this -> storage -> getUserMode ( $ nick , $ chan ) ; if ( ! $ userMode ) { $ userMode = self :: REGULAR ; } switch ( $ operation ) { case '+' : $ userMode |= $ mode ; break ; case '-' : $ userMode ^= $ mode ; break ; } $ this -> storage -> setUserMode ( $ nick , $ chan , $ userMode ) ; } }
Tracks user mode changes

@param  Event  $event Event object
Tracks user mode changes