From 3bfe5a31edb4d42f25926cfc5dcd86e104670256 Mon Sep 17 00:00:00 2001 From: ueno Date: Tue, 3 Jun 2003 02:49:22 +0000 Subject: [PATCH] * riece-rdcc.el: Require 'riece-ctcp. (riece-rdcc-insinuate): Add "DCC" to riece-ctcp-additional-clientinfo. * riece-ctcp.el (riece-ctcp-additional-clientinfo): New variable. (riece-command-ctcp-clientinfo): New command. (riece-ctcp-insinuate): Bind it in riece-dialogue-mode-map. (riece-handle-ctcp-clientinfo-request): New handler. (riece-handle-ctcp-clientinfo-response): New handler. * riece-server.el (riece-open-server): No need to use get-buffer-create to reuse process buffer. --- lisp/ChangeLog | 15 +++++++++++++ lisp/riece-ctcp.el | 60 +++++++++++++++++++++++++++++++++++++++++++++++++- lisp/riece-rdcc.el | 2 ++ lisp/riece-server.el | 7 +++--- 4 files changed, 79 insertions(+), 5 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 035ef5a..9b4084a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,20 @@ 2003-06-03 Daiki Ueno + * riece-rdcc.el: Require 'riece-ctcp. + (riece-rdcc-insinuate): Add "DCC" to + riece-ctcp-additional-clientinfo. + + * riece-ctcp.el (riece-ctcp-additional-clientinfo): New variable. + (riece-command-ctcp-clientinfo): New command. + (riece-ctcp-insinuate): Bind it in riece-dialogue-mode-map. + (riece-handle-ctcp-clientinfo-request): New handler. + (riece-handle-ctcp-clientinfo-response): New handler. + + * riece-server.el (riece-open-server): No need to use + get-buffer-create to reuse process buffer. + +2003-06-03 Daiki Ueno + * riece-rdcc.el (riece-command-dcc-send): Generate new buffer for DCC process. (riece-command-dcc-receive): Likewise; don't set buffer-file-name. diff --git a/lisp/riece-ctcp.el b/lisp/riece-ctcp.el index d86eb42..b878347 100644 --- a/lisp/riece-ctcp.el +++ b/lisp/riece-ctcp.el @@ -28,6 +28,7 @@ (require 'riece-misc) (defvar riece-ctcp-ping-time nil) +(defvar riece-ctcp-additional-clientinfo nil) (defvar riece-dialogue-mode-map) @@ -36,7 +37,8 @@ (add-hook 'riece-notice-hook 'riece-handle-ctcp-response) (define-key riece-dialogue-mode-map "\C-cv" 'riece-command-ctcp-version) (define-key riece-dialogue-mode-map "\C-cp" 'riece-command-ctcp-ping) - (define-key riece-dialogue-mode-map "\C-ca" 'riece-command-ctcp-action)) + (define-key riece-dialogue-mode-map "\C-ca" 'riece-command-ctcp-action) + (define-key riece-dialogue-mode-map "\C-cc" 'riece-command-ctcp-clientinfo)) (defun riece-handle-ctcp-request (prefix string) (when (and prefix string @@ -125,6 +127,43 @@ target)) "\n")))) +(defun riece-handle-ctcp-clientinfo-request (prefix target string) + (let ((buffer (if (riece-channel-p target) + (cdr (riece-identity-assoc-no-server + (riece-make-identity target) + riece-channel-buffer-alist)))) + (user (riece-prefix-nickname prefix))) + (riece-send-string + (format "NOTICE %s :\1CLIENTINFO %s\1\r\n" + user + (let (messages) + (mapatoms + (lambda (atom) + (let ((case-fold-search t)) + (if (and (fboundp atom) + (string-match + "riece-handle-ctcp-\\(.+\\)-request" + (symbol-name atom))) + (setq messages + (cons (match-string 1 (symbol-name atom)) + messages)))))) + (mapconcat #'upcase (append messages + riece-ctcp-additional-clientinfo) + " ")))) + (riece-insert-change buffer (format "CTCP CLIENTINFO from %s\n" user)) + (riece-insert-change + (if (and riece-channel-buffer-mode + (not (eq buffer riece-channel-buffer))) + (list riece-dialogue-buffer riece-others-buffer) + riece-dialogue-buffer) + (concat + (riece-concat-server-name + (format "CTCP CLIENTINFO from %s (%s) to %s" + user + (riece-strip-user-at-host (riece-prefix-user-at-host prefix)) + target)) + "\n")))) + (defun riece-handle-ctcp-action-request (prefix target string) (let ((buffer (if (riece-channel-p target) (cdr (riece-identity-assoc-no-server @@ -204,6 +243,17 @@ elapsed)) "\n")))) +(defun riece-handle-ctcp-clientinfo-response (prefix target string) + (riece-insert-change + (list riece-dialogue-buffer riece-others-buffer) + (concat + (riece-concat-server-name + (format "CTCP CLIENTINFO for %s (%s) = %s" + (riece-prefix-nickname prefix) + (riece-strip-user-at-host (riece-prefix-user-at-host prefix)) + string)) + "\n"))) + (defun riece-command-ctcp-version (user) (interactive (let ((completion-ignore-case t)) @@ -221,6 +271,14 @@ (riece-send-string (format "PRIVMSG %s :\1PING\1\r\n" user)) (setq riece-ctcp-ping-time (current-time))) +(defun riece-command-ctcp-clientinfo (user) + (interactive + (let ((completion-ignore-case t)) + (list (completing-read + "Channel/User: " + (mapcar #'list (riece-get-users-on-server)))))) + (riece-send-string (format "PRIVMSG %s :\1CLIENTINFO\1\r\n" user))) + (defun riece-command-ctcp-action (channel action) (interactive (list (if current-prefix-arg diff --git a/lisp/riece-rdcc.el b/lisp/riece-rdcc.el index ae16c9d..48c3809 100644 --- a/lisp/riece-rdcc.el +++ b/lisp/riece-rdcc.el @@ -27,6 +27,7 @@ (require 'riece-misc) (require 'riece-channel) (require 'riece-identity) +(require 'riece-ctcp) ;for riece-ctcp-additional-clientinfo (defgroup riece-rdcc nil "DCC implementation using ruby" @@ -294,6 +295,7 @@ puts(\"#{" address " >> 24 & 0xFF}.#{" address " >> 16 & 0xFF}.#{" (defvar riece-dialogue-mode-map) (defun riece-rdcc-insinuate () + (add-to-list 'riece-ctcp-additional-clientinfo "DCC" t) (add-hook 'riece-ctcp-dcc-request-hook 'riece-handle-dcc-request) (define-key riece-dialogue-mode-map "\C-ds" 'riece-command-dcc-send) (define-key riece-dialogue-mode-map "\C-dr" 'riece-command-dcc-receive)) diff --git a/lisp/riece-server.el b/lisp/riece-server.el index 9a47c35..4ff95c7 100644 --- a/lisp/riece-server.el +++ b/lisp/riece-server.el @@ -112,10 +112,9 @@ the `riece-server-keyword-map' variable." (coding-system-for-write 'binary) (process (funcall function "IRC" - (get-buffer-create - (if server-name - (format " *IRC*%s" server-name) - " *IRC*")) + (if server-name + (format " *IRC*%s" server-name) + " *IRC*") host service))) (riece-reset-process-buffer process) (with-current-buffer (process-buffer process) -- 1.7.10.4