From bmastenbrook at common-lisp.net Tue Nov 16 22:35:03 2004 From: bmastenbrook at common-lisp.net (Brian Mastenbrook) Date: Tue, 16 Nov 2004 23:35:03 +0100 Subject: [Cl-irc-cvs] CVS update: cl-irc/example/specbot.lisp Message-ID: Update of /project/cl-irc/cvsroot/cl-irc/example In directory common-lisp.net:/tmp/cvs-serv3365/example Modified Files: specbot.lisp Log Message: cocoa lookup Date: Tue Nov 16 23:35:03 2004 Author: bmastenbrook Index: cl-irc/example/specbot.lisp diff -u cl-irc/example/specbot.lisp:1.9 cl-irc/example/specbot.lisp:1.10 --- cl-irc/example/specbot.lisp:1.9 Tue Oct 26 03:38:49 2004 +++ cl-irc/example/specbot.lisp Tue Nov 16 23:35:02 2004 @@ -1,4 +1,4 @@ -;;;; $Id: specbot.lisp,v 1.9 2004/10/26 01:38:49 bmastenbrook Exp $ +;;;; $Id: specbot.lisp,v 1.10 2004/11/16 22:35:02 bmastenbrook Exp $ ;;;; $Source: /project/cl-irc/cvsroot/cl-irc/example/specbot.lisp,v $ ;;;; specbot.lisp - an example IRC bot for cl-irc @@ -46,6 +46,11 @@ (funcall (intern "SYMBOL-LOOKUP" :r5rs-lookup) str))) +(defun cocoa-lookup (str) + (and (find-package :cocoa-lookup) + (funcall (intern "SYMBOL-LOOKUP" :cocoa-lookup) + str))) + (defun elisp-lookup (str) (and (find-package :elisp-lookup) (funcall (intern "SYMBOL-LOOKUP" :elisp-lookup) @@ -59,6 +64,7 @@ (defvar *spec-providers* '((clhs-lookup "clhs" "The Common Lisp HyperSpec") (r5rs-lookup "r5rs" "The Revised 5th Ed. Report on the Algorithmic Language Scheme") + (cocoa-lookup "cocoa" "Classes in the Cocoa Foundation and Application kits") (elisp-lookup "elisp" "GNU Emacs Lisp Reference Manual") (clim-lookup "clim" "Common Lisp Interface Manager II Specification"))) From bmastenbrook at common-lisp.net Tue Nov 16 22:45:30 2004 From: bmastenbrook at common-lisp.net (Brian Mastenbrook) Date: Tue, 16 Nov 2004 23:45:30 +0100 Subject: [Cl-irc-cvs] CVS update: cl-irc/example/specbot.lisp Message-ID: Update of /project/cl-irc/cvsroot/cl-irc/example In directory common-lisp.net:/tmp/cvs-serv3826/example Modified Files: specbot.lisp Log Message: better help Date: Tue Nov 16 23:45:28 2004 Author: bmastenbrook Index: cl-irc/example/specbot.lisp diff -u cl-irc/example/specbot.lisp:1.10 cl-irc/example/specbot.lisp:1.11 --- cl-irc/example/specbot.lisp:1.10 Tue Nov 16 23:35:02 2004 +++ cl-irc/example/specbot.lisp Tue Nov 16 23:45:27 2004 @@ -1,4 +1,4 @@ -;;;; $Id: specbot.lisp,v 1.10 2004/11/16 22:35:02 bmastenbrook Exp $ +;;;; $Id: specbot.lisp,v 1.11 2004/11/16 22:45:27 bmastenbrook Exp $ ;;;; $Source: /project/cl-irc/cvsroot/cl-irc/example/specbot.lisp,v $ ;;;; specbot.lisp - an example IRC bot for cl-irc @@ -109,12 +109,13 @@ (member to-lookup '("help" "help?") :test #'string-equal)) (progn (privmsg *connection* destination - (format nil "To use the ~A bot, say something like \"database term\", where database is one of (~{~S~^, ~}) and term is the desired lookup." + (format nil "To use the ~A bot, say something like \"database term\", where database is one of (~{~S~^, ~}) and term is the desired lookup. The available databases are:" *nickname* (mapcar #'second *spec-providers*))) - (privmsg *connection* destination - (format nil "The available databases are: ~{~{~*~S, ~A~}~^; ~}" - *spec-providers*))) + (loop for (a b c d) on *spec-providers* by #'cddddr + do (privmsg *connection* destination + "~@{~{~*~S, ~A~}~}~}" a b c d)) + ) (loop for type in *spec-providers* for actual-fun = (if (typep (first type) 'symbol) (first type) From bmastenbrook at common-lisp.net Tue Nov 23 02:54:09 2004 From: bmastenbrook at common-lisp.net (Brian Mastenbrook) Date: Tue, 23 Nov 2004 03:54:09 +0100 Subject: [Cl-irc-cvs] CVS update: cl-irc/example/cliki.lisp cl-irc/example/specbot.lisp Message-ID: Update of /project/cl-irc/cvsroot/cl-irc/example In directory common-lisp.net:/home/bmastenbrook/cl-irc/example Modified Files: cliki.lisp specbot.lisp Log Message: apropos searching; new module for specbot? Date: Tue Nov 23 03:54:08 2004 Author: bmastenbrook Index: cl-irc/example/cliki.lisp diff -u cl-irc/example/cliki.lisp:1.27 cl-irc/example/cliki.lisp:1.28 --- cl-irc/example/cliki.lisp:1.27 Wed Oct 20 22:21:33 2004 +++ cl-irc/example/cliki.lisp Tue Nov 23 03:54:08 2004 @@ -1,4 +1,4 @@ - ;;;; $Id: cliki.lisp,v 1.27 2004/10/20 20:21:33 bmastenbrook Exp $ +;;;; $Id: cliki.lisp,v 1.28 2004/11/23 02:54:08 bmastenbrook Exp $ ;;;; $Source: /project/cl-irc/cvsroot/cl-irc/example/cliki.lisp,v $ ;;;; cliki.lisp - CLiki as an infobot; only works on SBCL. @@ -70,6 +70,14 @@ (push (cons term defn) *aliases*) (write-top-definition :of *aliases* :type :alias)) +(defun cliki-apropos (search-string) + (let ((found (remove-duplicates + (loop for (term . defn) in *small-definitions* + if (search search-string defn :test #'string-equal) + collect term) :test #'string-equal))) + (if found (format nil "Matches: ~{~S~^ ~}" found) + "No Matches"))) + (defvar *lookup-depth* 0) (defvar *followed-aliases* nil) @@ -416,7 +424,10 @@ (format nil "If you say multiple words to me which I don't recognize and it's not found as a lookup, you might get a sarcastic reply. Don't abuse this too much."))) ("advice" . ,(lambda (nick) - (format nil "Try saying something like ``~A: advice #11904'' to get some advice." nick))))) + (format nil "Try saying something like ``~A: advice #11904'' to get some advice." nick))) + ("apropos" . + ,(lambda (nick) + (format nil "Try ``~A: apropos foo'' to search for all small definitions containing ''foo''." nick))))) (defun cliki-bot-help (nick) (format nil "There are multiple help modules. Try ``/msg ~A help kind'', where kind is one of: ~{\"~A\"~^, ~}." @@ -650,6 +661,9 @@ (if (scan "^(?i)(?i)do my bidding!*$" first-pass) "Yes, my master.") (if (scan "^(?i)chant(\\s|!|\\?|\\.|$)*" first-pass) (format nil "MORE ~A" *more*)) + (let ((str (nth-value 1 (scan-to-strings "^(?i)apropos\\s+(.+\\S)\\s*$" first-pass)))) + (and str + (cliki-apropos (elt str 0)))) (if (scan "^(?i)advice$" first-pass) (random-advice)) (let ((str (nth-value 1 (scan-to-strings "^(?i)advise\\s+(for\\s+|)(\\S+)$" first-pass)))) Index: cl-irc/example/specbot.lisp diff -u cl-irc/example/specbot.lisp:1.11 cl-irc/example/specbot.lisp:1.12 --- cl-irc/example/specbot.lisp:1.11 Tue Nov 16 23:45:27 2004 +++ cl-irc/example/specbot.lisp Tue Nov 23 03:54:08 2004 @@ -1,4 +1,4 @@ -;;;; $Id: specbot.lisp,v 1.11 2004/11/16 22:45:27 bmastenbrook Exp $ +;;;; $Id: specbot.lisp,v 1.12 2004/11/23 02:54:08 bmastenbrook Exp $ ;;;; $Source: /project/cl-irc/cvsroot/cl-irc/example/specbot.lisp,v $ ;;;; specbot.lisp - an example IRC bot for cl-irc @@ -112,9 +112,15 @@ (format nil "To use the ~A bot, say something like \"database term\", where database is one of (~{~S~^, ~}) and term is the desired lookup. The available databases are:" *nickname* (mapcar #'second *spec-providers*))) - (loop for (a b c d) on *spec-providers* by #'cddddr - do (privmsg *connection* destination - "~@{~{~*~S, ~A~}~}~}" a b c d)) + (loop for i from 1 for j in *spec-providers* + with elts = nil + do (push j elts) + if (zerop (mod i 4)) + do (progn + (privmsg *connection* destination + (format nil "~{~{~*~S, ~A~}~^; ~}" + (nreverse elts))) + (setf elts nil))) ) (loop for type in *spec-providers* for actual-fun = (if (typep (first type) 'symbol)