Function: erc-server-send

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

Signature

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

Documentation

Send STRING to the current server.

When FORCE is non-nil, bypass flood protection so that STRING is sent directly without modifying the queue. When FORCE is the symbol no-penalty, exempt this round from accumulating a timeout penalty.

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 force target)
  "Send STRING to the current server.
When FORCE is non-nil, bypass flood protection so that STRING is
sent directly without modifying the queue.  When FORCE is the
symbol `no-penalty', exempt this round from accumulating a
timeout penalty.

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 force
                (progn
                  (unless (eq force 'no-penalty)
                    (cl-incf erc-server-flood-last-message
                             erc-server-flood-penalty))
                  (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)))