[net-nittin-irc-cvs] CVS update: net-nittin-irc/example/clhs.lisp

Brian Mastenbrook bmastenbrook at common-lisp.net
Mon Nov 17 14:04:28 UTC 2003


Update of /project/net-nittin-irc/cvsroot/net-nittin-irc/example
In directory common-lisp.net:/tmp/cvs-serv8784

Modified Files:
	clhs.lisp 
Log Message:
Bugfixen

Date: Mon Nov 17 09:04:28 2003
Author: bmastenbrook

Index: net-nittin-irc/example/clhs.lisp
diff -u net-nittin-irc/example/clhs.lisp:1.2 net-nittin-irc/example/clhs.lisp:1.3
--- net-nittin-irc/example/clhs.lisp:1.2	Fri Nov 14 15:35:22 2003
+++ net-nittin-irc/example/clhs.lisp	Mon Nov 17 09:04:28 2003
@@ -1,4 +1,4 @@
-;;;; $Id: clhs.lisp,v 1.2 2003/11/14 20:35:22 bmastenbrook Exp $
+;;;; $Id: clhs.lisp,v 1.3 2003/11/17 14:04:28 bmastenbrook Exp $
 ;;;; $Source: /project/net-nittin-irc/cvsroot/net-nittin-irc/example/clhs.lisp,v $
 
 ;;;; clhs.lisp - an example IRC bot for net-nittin-irc
@@ -19,12 +19,10 @@
 (defpackage :clhs (:use :common-lisp :irc))
 (in-package :clhs)
 
-(defparameter *table* (make-hash-table :test 'equalp))
-
 ;;; CLHS. This will be the default lookup.
-(defparameter *hyperspec-map-file* #p"HyperSpec/Data/Map_Sym.txt")
+(defparameter *hyperspec-pathname* #p"/home/chandler/public_html/HyperSpec/")
 
-(defparameter *hyperspec-pathname* #p"HyperSpec/")
+(defparameter *hyperspec-map-file* (merge-pathnames "Data/Map_Sym.txt" *hyperspec-pathname*))
 
 (defparameter *hyperspec-root* "http://www.lispworks.com/reference/HyperSpec/")
 
@@ -32,6 +30,8 @@
 (defparameter *mop-map-file* #p"Mop_Sym.txt")
 
 (defparameter *mop-root* "http://www.alu.org/mop/")
+
+(defparameter *table* (make-hash-table :test 'equalp))
                                                    
 (defun add-clhs-section-to-table (&rest numbers)
   (let ((key (format nil "~{~d~^.~}" numbers))
@@ -144,12 +144,17 @@
 
 (defparameter *clhs-attention-prefix* "clhs ")
 
+(defun valid-clhs-message (message)
+  (if (eql (search *clhs-attention-prefix* (trailing-argument message) :test #'char-equal) 0)
+    (not (find #\space (trailing-argument message) :start (length *clhs-attention-prefix*)))
+    nil))
+
 (defun msg-hook (message)
   (if (string-equal (first (arguments message)) *clhs-nickname*)
-      (if (eql (search *clhs-attention-prefix* (trailing-argument message) :test #'char-equal) 0)
+      (if (valid-clhs-message message)
           (privmsg *clhs-connection* (source message) (spec-lookup (subseq (trailing-argument message) (length *clhs-attention-prefix*))))
         (privmsg *clhs-connection* (source message) (spec-lookup (trailing-argument message))))
-    (if (search *clhs-attention-prefix* (trailing-argument message) :test #'char-equal)
+    (if (valid-clhs-message message)
         (privmsg *clhs-connection* (first (arguments message)) (spec-lookup (subseq (trailing-argument message) (length *clhs-attention-prefix*)))))))
 
 (defun start-clhs-bot (nick server &rest channels)
@@ -159,4 +164,8 @@
   (mapcar #'(lambda (channel) (join *clhs-connection* channel)) channels)
   (add-hook *clhs-connection* 'irc::irc-privmsg-message #'msg-hook)
   #+sbcl (add-asynchronous-message-handler *clhs-connection*)
-  #-sbcl (read-message-loop *clhs-connection*))
\ No newline at end of file
+  #-sbcl (read-message-loop *clhs-connection*))
+
+(defun shuffle-hooks ()
+  (irc::remove-hooks *clhs-connection* 'irc::irc-privmsg-message)
+  (add-hook *clhs-connection* 'irc::irc-privmsg-message #'msg-hook))





More information about the Net-nittin-irc-cvs mailing list