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))
(when buffer
(with-current-buffer buffer
;; 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
(setcar erc-server-last-peers nick)
(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)))
(when (string= cmd "PRIVMSG")
(erc-auto-query proc parsed))))))