private function listen()
    {
        do {
            $data = fgets($this->socket, 512);
            if (!empty($data)) {
                $request   = $this->receive($data);
                $cmd       = strtolower($request->getCommand());

                if ($cmd === 'privmsg') {
                    $event_name = 'message.' . ($request->isPrivateMessage() ? 'private' : 'channel');
                } else {
                    $event_name = 'server.' . $cmd;
                }

                // Skip processing if the incoming message is from the bot
                if ($request->getSendingUser() === $this->config['nick']) {
                    continue;
                }

                $event = new Event($request);
                $this->dispatcher->dispatch($event_name, $event);
                $responses = $event->getResponses();

                if (!empty($responses)) {
                    $this->send($responses);
                }
            }
        } while (!feof($this->socket) && false === $this->askStop);
    }
private function listen()
    {
        do {
            $data = fgets($this->socket, 512);
            if (!empty($data)) {
                $request   = $this->receive($data);
                $cmd       = strtolower($request->getCommand());

                if ($cmd === 'privmsg') {
                    $event_name = 'message.' . ($request->isPrivateMessage() ? 'private' : 'channel');
                } else {
                    $event_name = 'server.' . $cmd;
                }

                // Skip processing if the incoming message is from the bot
                if ($request->getSendingUser() === $this->config['nick']) {
                    continue;
                }

                $event = new Event($request);
                $this->dispatcher->dispatch($event_name, $event);
                $responses = $event->getResponses();

                if (!empty($responses)) {
                    $this->send($responses);
                }
            }
        } while (!feof($this->socket) && false === $this->askStop);
    }
private function listen ( ) { do { $ data = fgets ( $ this -> socket , 512 ) ; if ( ! empty ( $ data ) ) { $ request = $ this -> receive ( $ data ) ; $ cmd = strtolower ( $ request -> getCommand ( ) ) ; if ( $ cmd === 'privmsg' ) { $ event_name = 'message.' . ( $ request -> isPrivateMessage ( ) ? 'private' : 'channel' ) ; } else { $ event_name = 'server.' . $ cmd ; } // Skip processing if the incoming message is from the bot if ( $ request -> getSendingUser ( ) === $ this -> config [ 'nick' ] ) { continue ; } $ event = new Event ( $ request ) ; $ this -> dispatcher -> dispatch ( $ event_name , $ event ) ; $ responses = $ event -> getResponses ( ) ; if ( ! empty ( $ responses ) ) { $ this -> send ( $ responses ) ; } } } while ( ! feof ( $ this -> socket ) && false === $ this -> askStop ) ; }
Driver of the bot; listens for messages, responds to them accordingly.
Driver of the bot ; listens for messages responds to them accordingly .