protected function getIrcMessage($type, array $params = array())
    {
        $message = '';
        if ($this->prefix) {
            $message .= ':' . $this->prefix . ' ';
        }
        $message .= $type;

        $params = array_filter($params, function($param) {
            return $param !== null;
        });
        if ($params) {
            $last = end($params);
            $params[key($params)] = ':' . $last; 
            $message .= ' ' . implode(' ', $params);
        }
        
        $message .= "\r\n";
        return $message;
    }