Function: erc-services-issue-ghost-and-retry-nick
erc-services-issue-ghost-and-retry-nick is a byte-compiled function
defined in erc-services.el.gz.
Signature
(erc-services-issue-ghost-and-retry-nick WANT)
Documentation
Ask NickServ to "GHOST" nickname WANT.
After which, attempt to grab WANT before the contending party reconnects. Assume the ERC user owns WANT and that the server's services suite lacks a "REGAIN" command.
Note that this function will only work for a specific services implementation and is meant primarily as an example for adapting as needed.
Source Code
;; Defined in /usr/src/emacs/lisp/erc/erc-services.el.gz
(defun erc-services-issue-ghost-and-retry-nick (want)
"Ask NickServ to \"GHOST\" nickname WANT.
After which, attempt to grab WANT before the contending party
reconnects. Assume the ERC user owns WANT and that the server's
services suite lacks a \"REGAIN\" command.
Note that this function will only work for a specific services
implementation and is meant primarily as an example for adapting
as needed."
;; While heuristics based on error text may seem brittle, consider
;; the fact that \"is not online\" has been present in Atheme's
;; \"GHOST\" responses since at least 2005.
(letrec ((attempts 3)
(on-notice
(lambda (_proc parsed)
(when-let* ((nick (erc-extract-nick
(erc-response.sender parsed)))
((erc-nick-equal-p nick "nickserv"))
(contents (erc-response.contents parsed))
(case-fold-search t)
((string-match (rx (or "ghost" "is not online"))
contents)))
(setq attempts 1)
(erc-server-send (concat "NICK " want) 'force))
(when (zerop (cl-decf attempts))
(remove-hook 'erc-server-NOTICE-functions on-notice t))
nil)))
(add-hook 'erc-server-NOTICE-functions on-notice nil t)
(erc-message "PRIVMSG" (concat "NickServ GHOST " want))))