diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index bbb7ccb..3fe252a 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el @@ -1528,6 +1528,31 @@ erc-handle-unknown-server-response parsed 'notice nil 'WALLOPS ?n nick ?m message)))) +(define-erc-response-handler (CAP) + "capabilities" nil + (let ((subcmd (nth 1 (erc-response.command-args parsed)))) + (cond + ((string-equal subcmd "LS") + (erc-display-message + parsed 'notice nil + 'CAPLS ?c (string-join + (cddr (erc-response.command-args parsed)) " "))) + ((string-equal subcmd "LIST") + (erc-display-message + parsed 'notice nil + 'CAPLIST ?c (string-join + (cddr (erc-response.command-args parsed)) " "))) + ((string-equal subcmd "ACK") + (erc-display-message + parsed 'notice nil + 'CAPACK ?c (string-join + (cddr (erc-response.command-args parsed)) " "))) + ((string-equal subcmd "NAK") + (erc-display-message + parsed '(notice error) nil + 'CAPNAK ?c (string-join + (cddr (erc-response.command-args parsed)) " ")))))) + (define-erc-response-handler (001) "Set `erc-server-current-nick' to reflect server settings and display the welcome message." nil @@ -2012,6 +2037,11 @@ erc-server-322-message (erc-display-message parsed 'notice 'active 's671 ?n nick ?a securemsg))) +(define-erc-response-handler (410) + "Invalid CAP subcommand" nil + (erc-display-message parsed '(notice error) nil 's410 + ?c (nth 1 (erc-response.command-args parsed)))) + (define-erc-response-handler (431 445 446 451 462 463 464 481 483 484 485 491 501 502) ;; 431 - No nickname given diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 8501e2c..72b52d0 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -3832,6 +3832,35 @@ erc-cmd-MASSUNBAN (defalias 'erc-cmd-MUB 'erc-cmd-MASSUNBAN) +(defun erc-cap-command (cmd param) + (erc-server-send + (format "CAP %s %s" cmd + (if (= (length param) 0) (nth 0 param) + (concat ":" (string-join param " "))))) + (erc-server-send "CAP END")) + +(defun erc-cmd-CAP (subcmd &rest params) + "IRCv3 Capability negotation. + +/cap REQ PARAMS requests a the server to enable capabilities PARAMS. +Capabilities prefixed with '-' are disabled. + +/cap ACK PARAMS acknowledges a change for capabilities PARAMS. Capabilities +prefixed with '-' are acknowledged as disabled. + +/cap LS lists capabilities supported by the server. + +/cap LIST lists capabilities associated with this connection. + +/cap END ends capability negotiation." + (cond + ((string= "REQ" (upcase subcmd)) + (erc-cap-command "REQ" params)) + ((string= "ACK" (upcase subcmd)) + (erc-cap-command "ACK" params)) + (t (erc-server-send (format "CAP %s %s" (upcase subcmd) + (string-join params " ")))))) + ;;;; End of IRC commands (defun erc-ensure-channel-name (channel) @@ -6544,6 +6573,10 @@ erc-define-catalog (undefined-ctcp . "Undefined CTCP query received. Silently ignored") (variable-not-bound . "Variable not bound!") (ACTION . "* %n %a") + (CAPACK . "Capability change acknowledged: %c") + (CAPLS . "Capabilities supported by the server: %c") + (CAPLIST . "Capabilities active on this connection: %c") + (CAPNAK . "Capability change was rejected for: %c") (CTCP-CLIENTINFO . "Client info for %n: %m") (CTCP-ECHO . "Echo %n: %m") (CTCP-FINGER . "Finger info for %n: %m") @@ -6609,6 +6642,7 @@ erc-define-catalog (s404 . "%c: Cannot send to channel") (s405 . "%c: You have joined too many channels") (s406 . "%n: There was no such nickname") + (s410 . "Invalid CAP subcommand: %c") (s412 . "No text to send") (s421 . "%c: Unknown command") (s431 . "No nickname given")