From: F. Jason Park Date: Sun, 24 Jul 2022 12:14:24 +0000 (-0700) Subject: Fix CTCP regression in erc-server-PRIVMSG X-Git-Tag: emacs-29.0.90~1447^2~723 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=4a5499910a114a5e8a8b41e04397c20dec14935b;p=emacs.git Fix CTCP regression in erc-server-PRIVMSG * lisp/erc/erc-backend.el (erc-server-PRIVMSG): Don't create a query buffer for non-ACTION CTCP messages. * test/lisp/erc/erc-scenarios-misc.el (erc-scenarios-dcc-chat-accept): Add test for basic DCC CHAT accept dialog. * test/lisp/erc/resources/dcc/chat/accept-dcc.eld: New file. * test/lisp/erc/resources/dcc/chat/accept.eld: New file. --- diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index 8be4894ecbb..46c96c1a749 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el @@ -1526,11 +1526,13 @@ add things to `%s' instead." (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))) - (if (and privp msgp (not (erc-is-message-ctcp-and-not-action-p msg))) + (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 diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 4b852b39045..3b127bbd492 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -4654,8 +4654,9 @@ a new window, but not to select it. See the documentation for (const :tag "Use current buffer" buffer) (const :tag "Use current buffer" t))) -;; FIXME either retire this or put it to use or more clearly explain -;; what it's supposed to do. It's currently only used by the obsolete +;; FIXME either retire this or put it to use after determining how +;; it's meant to work. Clearly, the doc string does not describe +;; current behavior. It's currently only used by the obsolete ;; function `erc-auto-query'. (defcustom erc-query-on-unjoined-chan-privmsg t "If non-nil create query buffer on receiving any PRIVMSG at all. diff --git a/test/lisp/erc/erc-scenarios-misc.el b/test/lisp/erc/erc-scenarios-misc.el index 9d6d5bc1d6a..ded620ccc1d 100644 --- a/test/lisp/erc/erc-scenarios-misc.el +++ b/test/lisp/erc/erc-scenarios-misc.el @@ -138,4 +138,43 @@ (should-not (get-buffer "$*")))) +(ert-deftest erc-scenarios-dcc-chat-accept () + :tags '(:expensive-test) + (erc-scenarios-common-with-cleanup + ((erc-scenarios-common-dialog "dcc/chat") + (dcc-server (erc-d-run "127.0.0.1" t "erc-dcc-server" 'accept-dcc + :ending "\n")) + (dcc-port (process-contact dcc-server :service)) + (dumb-server (erc-d-run "localhost" t 'accept :tmpl-vars + `((port . ,(number-to-string dcc-port))))) + (port (process-contact dumb-server :service)) + (expect (erc-d-t-make-expecter))) + + (ert-info ("Connect to foonet") + (with-current-buffer (erc :server "127.0.0.1" + :port port + :nick "tester" + :password "changeme" + :full-name "tester") + (should (string= (buffer-name) (format "127.0.0.1:%d" port))))) + + (ert-info ("Offer received") + (with-current-buffer (erc-d-t-wait-for 10 (get-buffer "foonet")) + (funcall expect 10 "DCC: chat offered by dummy") + (erc-cmd-DCC "CHAT" "dummy"))) + + ;; Regression + (erc-d-t-ensure-for 1 (not (get-buffer "tester"))) + + ;; Becomes current buffer by default (because `erc-join-buffer') + (erc-d-t-wait-for 10 (get-buffer "DCC-CHAT-dummy")) + + (with-current-buffer "foonet" + (funcall expect 10 "*** DCC: accepting chat from dummy")) + + (ert-info ("Chat with dummy") + (with-current-buffer "DCC-CHAT-dummy" + (erc-scenarios-common-say "Hi") + (funcall expect 10 "Hola"))))) + ;;; erc-scenarios-misc.el ends here diff --git a/test/lisp/erc/resources/dcc/chat/accept-dcc.eld b/test/lisp/erc/resources/dcc/chat/accept-dcc.eld new file mode 100644 index 00000000000..23828a8115e --- /dev/null +++ b/test/lisp/erc/resources/dcc/chat/accept-dcc.eld @@ -0,0 +1,3 @@ +;; -*- mode: lisp-data; -*- +((open 10 "Hi") + (0 "Hola")) diff --git a/test/lisp/erc/resources/dcc/chat/accept.eld b/test/lisp/erc/resources/dcc/chat/accept.eld new file mode 100644 index 00000000000..a23e9580bcc --- /dev/null +++ b/test/lisp/erc/resources/dcc/chat/accept.eld @@ -0,0 +1,23 @@ +;; -*- mode: lisp-data; -*- +((pass 1 "PASS :changeme")) +((nick 1 "NICK tester")) +((user 1 "USER user 0 * :tester") + (0 ":irc.foonet.org 001 tester :Welcome to the foonet IRC Network tester") + (0 ":irc.foonet.org 002 tester :Your host is irc.foonet.org, running version oragono-2.6.0-7481bf0385b95b16") + (0 ":irc.foonet.org 003 tester :This server was created Mon, 31 May 2021 09:56:24 UTC") + (0 ":irc.foonet.org 004 tester irc.foonet.org oragono-2.6.0-7481bf0385b95b16 BERTZios CEIMRUabefhiklmnoqstuv Iabefhkloqv") + (0 ":irc.foonet.org 005 tester AWAYLEN=390 BOT=B CASEMAPPING=ascii CHANLIMIT=#:100 CHANMODES=Ibe,k,fl,CEMRUimnstu CHANNELLEN=64 CHANTYPES=# ELIST=U EXCEPTS EXTBAN=,m FORWARD=f INVEX KICKLEN=390 :are supported by this server") + (0 ":irc.foonet.org 005 tester MAXLIST=beI:60 MAXTARGETS=4 MODES MONITOR=100 NETWORK=foonet NICKLEN=32 PREFIX=(qaohv)~&@%+ STATUSMSG=~&@%+ TARGMAX=NAMES:1,LIST:1,KICK:1,WHOIS:1,USERHOST:10,PRIVMSG:4,TAGMSG:4,NOTICE:4,MONITOR:100 TOPICLEN=390 UTF8MAPPING=rfc8265 UTF8ONLY WHOX :are supported by this server") + (0 ":irc.foonet.org 005 tester draft/CHATHISTORY=100 :are supported by this server") + (0 ":irc.foonet.org 251 tester :There are 0 users and 4 invisible on 1 server(s)") + (0 ":irc.foonet.org 252 tester 0 :IRC Operators online") + (0 ":irc.foonet.org 254 tester 2 :channels formed") + (0 ":irc.foonet.org 255 tester :I have 4 clients and 0 servers") + (0 ":irc.foonet.org 265 tester 4 4 :Current local users 4, max 4") + (0 ":irc.foonet.org 266 tester 4 4 :Current global users 4, max 4") + (0 ":irc.foonet.org 422 tester :MOTD File is missing")) + +((mode-user 1.2 "MODE tester +i") + ;; No mode answer + (0 ":irc.foonet.org NOTICE tester :This server is in debug mode and is logging all user I/O. If you do not wish for everything you send to be readable by the server owner(s), please disconnect.") + (0.2 ":dummy!~u@34n9brushbpj2.irc PRIVMSG tester :\C-aDCC CHAT chat 2130706433 " port "\C-a"))