protected static function getEvent(Closure $action)
    {
        return function (Update $update) use ($action) {
            $message = $update->getMessage();
            if (!$message) {
                return true;
            }

            preg_match(self::REGEXP, $message->getText(), $matches);

            if (isset($matches[3]) && !empty($matches[3])) {
                $parameters = str_getcsv($matches[3], chr(32));
            } else {
                $parameters = [];
            }

            array_unshift($parameters, $message);

            $action = new ReflectionFunction($action);

            if (count($parameters) >= $action->getNumberOfRequiredParameters()) {
                $action->invokeArgs($parameters);
            }

            return false;
        };
    }
protected static function getEvent(Closure $action)
    {
        return function (Update $update) use ($action) {
            $message = $update->getMessage();
            if (!$message) {
                return true;
            }

            preg_match(self::REGEXP, $message->getText(), $matches);

            if (isset($matches[3]) && !empty($matches[3])) {
                $parameters = str_getcsv($matches[3], chr(32));
            } else {
                $parameters = [];
            }

            array_unshift($parameters, $message);

            $action = new ReflectionFunction($action);

            if (count($parameters) >= $action->getNumberOfRequiredParameters()) {
                $action->invokeArgs($parameters);
            }

            return false;
        };
    }
protected static function getEvent ( Closure $ action ) { return function ( Update $ update ) use ( $ action ) { $ message = $ update -> getMessage ( ) ; if ( ! $ message ) { return true ; } preg_match ( self :: REGEXP , $ message -> getText ( ) , $ matches ) ; if ( isset ( $ matches [ 3 ] ) && ! empty ( $ matches [ 3 ] ) ) { $ parameters = str_getcsv ( $ matches [ 3 ] , chr ( 32 ) ) ; } else { $ parameters = [ ] ; } array_unshift ( $ parameters , $ message ) ; $ action = new ReflectionFunction ( $ action ) ; if ( count ( $ parameters ) >= $ action -> getNumberOfRequiredParameters ( ) ) { $ action -> invokeArgs ( $ parameters ) ; } return false ; } ; }
Returns event function to handling the command.

@param \Closure $action

@return \Closure
Returns event function to handling the command .