bone282 commented on a Page, PHP IRC Bot v2  -  Apr 19, 2009

you could try this it may be slower than explode but you're only talking milliseconds..

/ Create An Infinite Loop.
while(1) {
    while($data = fgets($socket)) {

        /* Seperate All Data */
        preg_match("/^:(.*?)!(.*?)@(.*?)[\s](.*?)[\s](.*?)[\s]:(.*?)$/",$data, $rawdata);
        $nick = $rawdata[1];
        $ident = $rawdata[2];
        $host = $rawdata[3];
        $msg_type = $rawdata[4];
        $channel = $rawdata[5]; 
        $message = rtrim($rawdata[6]);
        $ex = explode(' ', $data);

        /* Create the Commands Trigger */
        $message = explode(" ", trim($message));
        $trigger = array_shift($message);
        $message = implode(" ", $message);

        /* Send PONG Back To The Server. */
        if($ex[0] == "PING"){ fputs($socket, "PONG ".$ex[1]."\n"); }
        ...
        ...

But keep using the $ex array for IRC events other than user events.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.