Function: erc-server-send

erc-server-send is a byte-compiled function defined in erc-backend.el.gz.

Signature

(erc-server-send STRING &optional FORCEP TARGET)

Documentation

Send STRING to the current server.

If FORCEP is non-nil, no flood protection is done - the string is sent directly. This might cause the messages to arrive in a wrong order.

If TARGET is specified, look up encoding information for that channel in erc-encoding-coding-alist or erc-server-coding-system.

See erc-server-flood-margin for an explanation of the flood protection algorithm.

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc-backend.el.gz
;; From Circe, with modifications
(defun erc-server-send (string &optional forcep target)
  "Send STRING to the current server.
If FORCEP is non-nil, no flood protection is done - the string is
sent directly.  This might cause the messages to arrive in a wrong
order.

If TARGET is specified, look up encoding information for that
channel in `erc-encoding-coding-alist' or
`erc-server-coding-system'.

See `erc-server-flood-margin' for an explanation of the flood
protection algorithm."
  (erc-log (concat "erc-server-send: " string "(" (buffer-name) ")"))
  (setq erc-server-last-sent-time (erc-current-time))
  (let ((encoding (erc-coding-system-for-target target)))
    (when (consp encoding)
      (setq encoding (car encoding)))
    (if (erc-server-process-alive)
        (erc-with-server-buffer
          (let ((str (concat string "\r\n")))
            (if forcep
                (progn
                  (setq erc-server-flood-last-message
                        (+ erc-server-flood-penalty
                           erc-server-flood-last-message))
                  (erc-log-irc-protocol str 'outbound)
                  (condition-case nil
                      (progn
                        ;; Set encoding just before sending the string
                        (when (fboundp 'set-process-coding-system)
                          (set-process-coding-system erc-server-process
                                                     'raw-text encoding))
                        (process-send-string erc-server-process str))
                    ;; See `erc-server-send-queue' for full
                    ;; explanation of why we need this condition-case
                    (error nil)))
              (setq erc-server-flood-queue
                    (append erc-server-flood-queue
                            (list (cons str encoding))))
              (erc-server-send-queue (current-buffer))))
          t)
      (message "ERC: No process running")
      nil)))