X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lisp%2Friece-doctor.el;h=1f07a629d8585a1e9c1c4cae75e1148b0a9e7449;hb=a722972ffd4407a7b24455493fc3b47aa21933c3;hp=022366ed83b3f1d7c8dcbe52d658e604cef610bd;hpb=b834bf2df318ea6fb5ae02406cca8262ae22c0db;p=elisp%2Friece.git diff --git a/lisp/riece-doctor.el b/lisp/riece-doctor.el index 022366e..1f07a62 100644 --- a/lisp/riece-doctor.el +++ b/lisp/riece-doctor.el @@ -35,21 +35,22 @@ (defvar riece-doctor-patients nil) (defun riece-doctor-buffer-name (user) - (concat " *riece-doctor*" (riece-identity-canonicalize-prefix user))) + (concat " *riece-doctor*" (riece-decode-identity user))) (defun riece-doctor-reply (target string) - (riece-send-string (format "NOTICE %s :%s\r\n" target string)) (riece-own-channel-message string (riece-make-identity target riece-server-name) - 'notice)) + 'notice) + (riece-send-string (format "NOTICE %s :%s\r\n" target string))) (defun riece-doctor-after-privmsg-hook (prefix string) - (let* ((user (riece-prefix-nickname prefix)) + (let* ((user (riece-make-identity (riece-prefix-nickname prefix) + riece-server-name)) (parameters (riece-split-parameters string)) (targets (split-string (car parameters) ",")) (message (nth 1 parameters))) (if (string-match "^, doctor" message) - (if (riece-identity-member-no-server user riece-doctor-patients) + (if (riece-identity-member user riece-doctor-patients) (riece-doctor-reply (car targets) "You are already talking with me.") @@ -62,31 +63,28 @@ (car targets) "I am the psychotherapist. Please, describe your problems.")) (if (string-match "^, bye doctor" message) - (let ((pointer (riece-identity-member-no-server - user riece-doctor-patients))) + (let ((pointer (riece-identity-member user riece-doctor-patients))) (when pointer (kill-buffer (riece-doctor-buffer-name user)) (setq riece-doctor-patients (delq (car pointer) riece-doctor-patients)) (riece-doctor-reply (car targets) "Good bye."))) - (when (riece-identity-member-no-server user riece-doctor-patients) - (riece-doctor-reply - (car targets) - (save-excursion - (set-buffer (get-buffer (riece-doctor-buffer-name user))) - (goto-char (point-max)) - (insert message "\n") - (let ((point (point)) - string) - (doctor-read-print) - (setq string (buffer-substring (1+ point)(- (point) 2))) - (with-temp-buffer - (insert string) - (subst-char-in-region (point-min) (point-max) ?\n ? ) - (buffer-string)))))))))) + (if (riece-identity-member user riece-doctor-patients) + (let (string) + (save-excursion + (set-buffer (get-buffer (riece-doctor-buffer-name user))) + (goto-char (point-max)) + (insert message "\n") + (let ((point (point))) + (doctor-read-print) + (setq string (buffer-substring (1+ point) (- (point) 2)))) + (with-temp-buffer + (insert string) + (subst-char-in-region (point-min) (point-max) ?\n ? ) + (setq string (buffer-string)))) + (riece-doctor-reply (car targets) string))))))) (defun riece-doctor-insinuate () - (make-variable-buffer-local 'riece-doctor-patients) (add-hook 'riece-after-privmsg-hook 'riece-doctor-after-privmsg-hook)) (provide 'riece-doctor)