Function: erc-server-PRIVMSG
erc-server-PRIVMSG is a byte-compiled function defined in
erc-backend.el.gz.
Signature
(erc-server-PRIVMSG PROC PARSED)
Documentation
Handle private messages, including messages in channels.
Handler for a PRIVMSG server response.
PROC is the server process which returned the response.
PARSED is the actual response as an erc-response struct.
If you want to add responses don't modify this function, but rather
add things to erc-server-PRIVMSG-functions instead.
Aliases
Source Code
;; Defined in /usr/src/emacs/lisp/erc/erc-backend.el.gz
(define-erc-response-handler (PRIVMSG NOTICE)
"Handle private messages, including messages in channels." nil
(let ((sender-spec (erc-response.sender parsed))
(cmd (erc-response.command parsed))
(tgt (car (erc-response.command-args parsed)))
(msg (erc-response.contents parsed)))
(if (or (erc-ignored-user-p sender-spec)
(erc-ignored-reply-p msg tgt proc))
(when erc-minibuffer-ignored
(message "Ignored %s from %s to %s" cmd sender-spec tgt))
(let* ((sndr (erc-parse-user sender-spec))
(nick (nth 0 sndr))
(login (nth 1 sndr))
(host (nth 2 sndr))
(msgp (string= cmd "PRIVMSG"))
(noticep (string= cmd "NOTICE"))
;; S.B. downcase *both* tgt and current nick
(privp (erc-current-nick-p tgt))
s buffer
fnick)
(setf (erc-response.contents parsed) msg)
(setq buffer (erc-get-buffer (if privp nick tgt) proc))
;; Even worth checking for empty target here? (invalid anyway)
(unless (or buffer noticep (string-empty-p tgt) (eq ?$ (aref tgt 0))
(erc-is-message-ctcp-and-not-action-p msg))
(if privp
(when erc-auto-query
(let ((erc-join-buffer erc-auto-query))
(setq buffer (erc--open-target nick))))
;; A channel buffer has been killed but is still joined
(setq buffer (erc--open-target tgt))))
(when buffer
(with-current-buffer buffer
(when privp (erc--unhide-prompt))
;; update the chat partner info. Add to the list if private
;; message. We will accumulate private identities indefinitely
;; at this point.
(erc-update-channel-member (if privp nick tgt) nick nick
privp nil nil nil nil nil host login nil nil t)
(let ((cdata (erc-get-channel-user nick)))
(setq fnick (funcall erc-format-nick-function
(car cdata) (cdr cdata))))))
(cond
((erc-is-message-ctcp-p msg)
(setq s (if msgp
(erc-process-ctcp-query proc parsed nick login host)
(erc-process-ctcp-reply proc parsed nick login host
(match-string 1 msg)))))
(t
(setq erc-server-last-peers (cons nick (cdr erc-server-last-peers)))
(setq s (erc-format-privmessage
(or fnick nick) msg
;; If buffer is a query buffer,
;; format the nick as for a channel.
(and (not (and buffer
(erc-query-buffer-p buffer)
erc-format-query-as-channel-p))
privp)
msgp))))
(when s
(if (and noticep privp)
(progn
(run-hook-with-args 'erc-echo-notice-always-hook
s parsed buffer nick)
(run-hook-with-args-until-success
'erc-echo-notice-hook s parsed buffer nick))
(erc-display-message parsed nil buffer s)))))))