X-Git-Url: https://cgit.sxemacs.org/?a=blobdiff_plain;f=lisp%2Friece-doctor.el;h=0c75ace4e226245ee1b962ef5bb681d2319b3ee1;hb=2ad73eb3332a97489a0c6cacf8e0cef7bb769b8f;hp=61a33f0561513298ed784830cba1f06c4c6c8eee;hpb=fe7eeb17a3b1cc9b6a5316aebae340cba1ede06d;p=riece diff --git a/lisp/riece-doctor.el b/lisp/riece-doctor.el index 61a33f0..0c75ace 100644 --- a/lisp/riece-doctor.el +++ b/lisp/riece-doctor.el @@ -1,4 +1,4 @@ -;;; riece-doctor.el --- "become a psychotherapist" add-on +;;; riece-doctor.el --- pretend to be a psychotherapist ;; Copyright (C) 1998-2003 Daiki Ueno ;; Author: Daiki Ueno @@ -18,15 +18,12 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. ;;; Commentary: -;; This add-on allows you to become a psychotherapist. - -;; To use, add the following line to your ~/.riece/init.el: -;; (add-to-list 'riece-addons 'riece-doctor) +;; NOTE: This is an add-on module for Riece. ;;; Code: @@ -36,26 +33,24 @@ (require 'riece-server) (defgroup riece-doctor nil - "Interface to doctor.el" + "Interface to doctor.el." :prefix "riece-" :group 'riece) -(defcustom riece-doctor-hello-regexp "^, doctor" +(defcustom riece-doctor-hello-regexp "^,doctor$" "Pattern of string patients start consultation." :type 'string :group 'riece-doctor) -(defcustom riece-doctor-bye-regexp "^, bye doctor" +(defcustom riece-doctor-bye-regexp "^,doctor bye$" "Pattern of string patients end consultation." :type 'string :group 'riece-doctor) (defvar riece-doctor-patients nil) -(defvar riece-doctor-enabled nil) - (defconst riece-doctor-description - "Allow users in channel to talk with the classic pseudo-AI") + "Pretend to be a psychotherapist.") (put 'riece-doctor 'riece-addon-default-disabled t) @@ -76,7 +71,7 @@ (riece-send-string (format "NOTICE %s :%s\r\n" target string))) (defun riece-doctor-after-privmsg-hook (prefix string) - (if riece-doctor-enabled + (if (get 'riece-doctor 'riece-addon-enabled) (let* ((user (riece-prefix-nickname prefix)) (parameters (riece-split-parameters string)) (targets (split-string (car parameters) ",")) @@ -86,9 +81,8 @@ (riece-doctor-reply (car targets) (format "%s: You are already talking with me." user)) - (save-excursion - (set-buffer (get-buffer-create - (riece-doctor-buffer-name user))) + (with-current-buffer (get-buffer-create + (riece-doctor-buffer-name user)) (erase-buffer) (doctor-mode)) (setq riece-doctor-patients (cons user riece-doctor-patients)) @@ -110,8 +104,7 @@ Please, describe your problems." (format "%s: Good bye." user)))) (if (riece-identity-member user riece-doctor-patients t) (let (string) - (save-excursion - (set-buffer (get-buffer (riece-doctor-buffer-name user))) + (with-current-buffer (riece-doctor-buffer-name user) (goto-char (point-max)) (insert message "\n") (let ((point (point))) @@ -129,11 +122,8 @@ Please, describe your problems." (defun riece-doctor-insinuate () (add-hook 'riece-after-privmsg-hook 'riece-doctor-after-privmsg-hook)) -(defun riece-doctor-enable () - (setq riece-doctor-enabled t)) - -(defun riece-doctor-disable () - (setq riece-doctor-enabled nil)) +(defun riece-doctor-uninstall () + (remove-hook 'riece-after-privmsg-hook 'riece-doctor-after-privmsg-hook)) (provide 'riece-doctor)