Function: erc-dcc-handle-ctcp-chat

erc-dcc-handle-ctcp-chat is a byte-compiled function defined in erc-dcc.el.gz.

Signature

(erc-dcc-handle-ctcp-chat PROC QUERY NICK LOGIN HOST TO)

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc-dcc.el.gz
(defun erc-dcc-handle-ctcp-chat (proc query nick login host to)
  (unless (eq erc-dcc-chat-request 'ignore)
    (cond
     (;; DCC CHAT requests must be sent to you, and you alone.
      (not (erc-current-nick-p to))
      (erc-display-message
       nil '(notice error) proc
       'dcc-request-bogus ?r "CHAT" ?n nick ?u login ?h host))
     ((string-match erc-dcc-ctcp-query-chat-regexp query)
      ;; We need to use let* here, since erc-dcc-member might clutter
      ;; the match value.
      (let* ((ip   (erc-decimal-to-ip (match-string 1 query)))
             (port (match-string 2 query))
             (elt  (erc-dcc-member :nick nick :type 'CHAT)))
        ;; FIXME: A warning really should also be sent if the ip
        ;; address != the host the dcc sender is on.
        (erc-display-message
         nil 'notice proc
         'dcc-chat-offered
         ?n nick ?u login ?h host ?p port)
        (and (< (string-to-number port) 1025)
             (erc-display-message
              nil 'notice proc
              'dcc-privileged-port ?p port))
        (cond (elt
               ;; XXX: why are we updating ip/port on the existing connection?
               (setq elt (plist-put (plist-put elt :port port) :ip ip))
               (erc-display-message
                nil 'notice proc
                'dcc-chat-discarded ?n nick ?u login ?h host))
              (t
               (erc-dcc-list-add
                'CHAT (format "%s!%s@%s" nick login host)
                nil proc
                :ip ip :port port)))
        (if (eq erc-dcc-chat-request 'auto)
            (erc-dcc-chat-accept (erc-dcc-member :nick nick :type 'CHAT)
                                 proc))))
     (t
      (erc-display-message
       nil '(notice error) proc
       'dcc-malformed ?n nick ?u login ?h host ?q query)))))