src/Bot.php
public function onText($regexp, \Closure $handler)
    {
        $this->managers[] = new Manager(function (Event $event) use ($regexp) {
            return (
                $event instanceof \Viber\Api\Event\Message
                && $event->getMessage() instanceof \Viber\Api\Message\Text
                && preg_match($regexp, $event->getMessage()->getText())
            );
        }, $handler);

        return $this;
    }
public function onText($regexp, \Closure $handler)
    {
        $this->managers[] = new Manager(function (Event $event) use ($regexp) {
            return (
                $event instanceof \Viber\Api\Event\Message
                && $event->getMessage() instanceof \Viber\Api\Message\Text
                && preg_match($regexp, $event->getMessage()->getText())
            );
        }, $handler);

        return $this;
    }
public function onText ( $ regexp , \ Closure $ handler ) { $ this -> managers [ ] = new Manager ( function ( Event $ event ) use ( $ regexp ) { return ( $ event instanceof \ Viber \ Api \ Event \ Message && $ event -> getMessage ( ) instanceof \ Viber \ Api \ Message \ Text && preg_match ( $ regexp , $ event -> getMessage ( ) -> getText ( ) ) ) ; } , $ handler ) ; return $ this ; }
Register text message handler by PCRE

@param  string $regexp valid regular expression
@param  Closure $handler event handler
@return \Viber\Bot
Register text message handler by PCRE