[Cl-irc-cvs] CVS update: cl-irc/example/clhs.lisp cl-irc/example/cliki.lisp

Brian Mastenbrook bmastenbrook at common-lisp.net
Tue Jun 1 15:29:19 UTC 2004


Update of /project/cl-irc/cvsroot/cl-irc/example
In directory common-lisp.net:/home/bmastenbrook/cl-irc/example

Modified Files:
	clhs.lisp cliki.lisp 
Log Message:
wootage! minion talks to lisppaste, if it can

Date: Tue Jun  1 08:29:19 2004
Author: bmastenbrook

Index: cl-irc/example/clhs.lisp
diff -u cl-irc/example/clhs.lisp:1.5 cl-irc/example/clhs.lisp:1.6
--- cl-irc/example/clhs.lisp:1.5	Tue Jun  1 06:48:12 2004
+++ cl-irc/example/clhs.lisp	Tue Jun  1 08:29:19 2004
@@ -1,4 +1,4 @@
-;;;; $Id: clhs.lisp,v 1.5 2004/06/01 13:48:12 bmastenbrook Exp $
+;;;; $Id: clhs.lisp,v 1.6 2004/06/01 15:29:19 bmastenbrook Exp $
 ;;;; $Source: /project/cl-irc/cvsroot/cl-irc/example/clhs.lisp,v $
 
 ;;;; clhs.lisp - an example IRC bot for cl-irc
@@ -20,7 +20,7 @@
 (in-package :clhs)
 
 ;;; CLHS. This will be the default lookup.
-(defparameter *hyperspec-pathname* #p"/Users/chandler/HyperSpec/")
+(defparameter *hyperspec-pathname* #p"/home/bmastenbrook/HyperSpec/")
 
 (defparameter *hyperspec-map-file* (merge-pathnames "Data/Map_Sym.txt" *hyperspec-pathname*))
 
@@ -77,7 +77,7 @@
                                                            do (add-clhs-section-to-table section s1 s2 s3 s4 s5))))))))
     ;; format directives
     (loop for code from 32 to 127
-          do (setf (gethash (format nil "format:~A" (code-char code)) *table*)
+          do (setf (gethash (format nil "~~~A" (code-char code)) *table*)
                    (concatenate 'string
                     *hyperspec-root*
                     (case (code-char code)


Index: cl-irc/example/cliki.lisp
diff -u cl-irc/example/cliki.lisp:1.5 cl-irc/example/cliki.lisp:1.6
--- cl-irc/example/cliki.lisp:1.5	Tue Jun  1 06:48:12 2004
+++ cl-irc/example/cliki.lisp	Tue Jun  1 08:29:19 2004
@@ -1,4 +1,4 @@
-;;;; $Id: cliki.lisp,v 1.5 2004/06/01 13:48:12 bmastenbrook Exp $
+;;;; $Id: cliki.lisp,v 1.6 2004/06/01 15:29:19 bmastenbrook Exp $
 ;;;; $Source: /project/cl-irc/cvsroot/cl-irc/example/cliki.lisp,v $
 
 ;;;; cliki.lisp - CLiki as an infobot; only works on SBCL.
@@ -174,7 +174,7 @@
 
 (defparameter *cliki-bot-help* "The minion bot supplies small definitions and performs lookups on CLiki. To use it, try ``minion: term?''. To add a term for IRC, try saying ``minion: add \"term\" as: definition'' or ``minion: alias \"term\" as: term''; otherwise, edit the corresponding CLiki page.")
 
-(defun cliki-lookup (term-with-question &optional sender)
+(defun cliki-lookup (term-with-question &key sender channel)
   (let ((first-pass (regex-replace-all "^(\\s*)([^?]+)(\\?*)$" term-with-question "\\2")))
     (setf first-pass (regex-replace-all "\\s\\s+" first-pass ""))
     (setf first-pass (regex-replace-all "\\s*$" first-pass ""))
@@ -190,6 +190,14 @@
 	      "OK, done.")
 	  (progn
 	    (setf first-pass (regex-replace-all "(:|/|\\\\|\\#)" first-pass ""))
+            (when (and (scan "^(?i)lisppaste(\\s|!|\\?|\\.|$)*" first-pass)
+                        (find-package :lisppaste)
+                        channel
+                        (> (length channel) 0)
+                        (char= (elt channel 0) #\#))
+               (funcall (intern "SAY-HELP" :lisppaste)
+                        channel)
+               (return-from cliki-lookup nil))
 	    (or
 	     (if (string-equal first-pass "help") *cliki-bot-help*)
              (if (scan "^(?i)hello(\\s|$)*" first-pass) "what's up?")
@@ -225,7 +233,8 @@
 (defun msg-hook (message)
   (let ((respond-to (if (string-equal (first (arguments message)) *cliki-nickname*) (source message) (first (arguments message)))))
     (if (valid-cliki-message message)
-	(privmsg *cliki-connection* respond-to (cliki-lookup (regex-replace *cliki-attention-prefix* (trailing-argument message) "") (source message)))
+        (let ((response (cliki-lookup (regex-replace *cliki-attention-prefix* (trailing-argument message) "") :sender (source message) :channel (first (irc:arguments message)))))
+          (and response (privmsg *cliki-connection* respond-to response)))
       (if (string-equal (first (arguments message)) *cliki-nickname*)
 	  (privmsg *cliki-connection* respond-to (cliki-lookup (trailing-argument message)))
 	(if (anybody-here (trailing-argument message))





More information about the cl-irc-cvs mailing list