Function: erc-nickserv-get-password
erc-nickserv-get-password is a byte-compiled function defined in
erc-services.el.gz.
Signature
(erc-nickserv-get-password NICK)
Documentation
Return the password for NICK from configured sources.
First, a password for NICK is looked up in
erc-nickserv-passwords. Then, it is looked up in auth-source
if erc-use-auth-source-for-nickserv-password is not nil.
Finally, interactively prompt the user, if
erc-prompt-for-nickserv-password is true.
As soon as some source returns a password, the sequence of lookups stops and this function returns it (or returns nil if it is empty). Otherwise, no corresponding password was found, and it returns nil.
Source Code
;; Defined in /usr/src/emacs/lisp/erc/erc-services.el.gz
(defun erc-nickserv-get-password (nick)
"Return the password for NICK from configured sources.
First, a password for NICK is looked up in
`erc-nickserv-passwords'. Then, it is looked up in auth-source
if `erc-use-auth-source-for-nickserv-password' is not nil.
Finally, interactively prompt the user, if
`erc-prompt-for-nickserv-password' is true.
As soon as some source returns a password, the sequence of
lookups stops and this function returns it (or returns nil if it
is empty). Otherwise, no corresponding password was found, and
it returns nil."
(let (network server port)
;; Fill in local vars, switching to the server buffer once only
(erc-with-server-buffer
(setq network erc-network
server erc-session-server
port erc-session-port))
(let ((ret
(or
(when erc-nickserv-passwords
(cdr (assoc nick
(cl-second (assoc network
erc-nickserv-passwords)))))
(when erc-use-auth-source-for-nickserv-password
(let ((secret (cl-first (auth-source-search
:max 1 :require '(:secret)
:host server
;; Ensure a string for :port
:port (format "%s" port)
:user nick))))
(when secret
(let ((passwd (plist-get secret :secret)))
(if (functionp passwd) (funcall passwd) passwd)))))
(when erc-prompt-for-nickserv-password
(read-passwd
(format "NickServ password for %s on %s (RET to cancel): "
nick network))))))
(when (and ret (not (string= ret "")))
ret))))