public function message($type, $destination, $messagearray,
        $priority = SMARTIRC_MEDIUM
    ) {
        if (!is_array($messagearray)) {
            $messagearray = array($messagearray);
        }

        switch ($type) {
            case SMARTIRC_TYPE_CHANNEL:
            case SMARTIRC_TYPE_QUERY:
                foreach ($messagearray as $message) {
                    $this->send('PRIVMSG '.$destination.' :'.$message, $priority);
                }
                break;

            case SMARTIRC_TYPE_ACTION:
                foreach ($messagearray as $message) {
                    $this->send('PRIVMSG '.$destination.' :'.chr(1).'ACTION '
                        .$message.chr(1), $priority
                    );
                }
                break;

            case SMARTIRC_TYPE_NOTICE:
                foreach ($messagearray as $message) {
                    $this->send('NOTICE '.$destination.' :'.$message, $priority);
                }
                break;

            case SMARTIRC_TYPE_CTCP: // backwards compatibility
            case SMARTIRC_TYPE_CTCP_REPLY:
                foreach ($messagearray as $message) {
                    $this->send('NOTICE '.$destination.' :'.chr(1).$message
                        .chr(1), $priority
                    );
                }
                break;

            case SMARTIRC_TYPE_CTCP_REQUEST:
                foreach ($messagearray as $message) {
                    $this->send('PRIVMSG '.$destination.' :'.chr(1).$message
                        .chr(1), $priority
                    );
                }
                break;

            default:
                return false;
        }

        return $this;
    }