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 eliza-rules.lisp
Log Message:
package cleanups, slight changes from current
Date: Sun Feb 1 09:11:56 2004
Author: bmastenbrook
Index: cl-irc/example/clhs.lisp
diff -u cl-irc/example/clhs.lisp:1.3 cl-irc/example/clhs.lisp:1.4
--- cl-irc/example/clhs.lisp:1.3 Thu Jan 22 15:51:16 2004
+++ cl-irc/example/clhs.lisp Sun Feb 1 09:11:56 2004
@@ -1,4 +1,4 @@
-;;;; $Id: clhs.lisp,v 1.3 2004/01/22 20:51:16 bmastenbrook Exp $
+;;;; $Id: clhs.lisp,v 1.4 2004/02/01 14:11:56 bmastenbrook Exp $
;;;; $Source: /project/cl-irc/cvsroot/cl-irc/example/clhs.lisp,v $
;;;; clhs.lisp - an example IRC bot for cl-irc
@@ -16,7 +16,7 @@
;;; invoke (clhs::start-clhs-bot "desirednickname" "desiredserver"
;;; "#channel1" "#channel2" "#channel3" ...)
-(defpackage :clhs (:use :common-lisp :irc))
+(defpackage :clhs (:use :common-lisp :irc) (:export :start-clhs-bot))
(in-package :clhs)
;;; CLHS. This will be the default lookup.
Index: cl-irc/example/cliki.lisp
diff -u cl-irc/example/cliki.lisp:1.3 cl-irc/example/cliki.lisp:1.4
--- cl-irc/example/cliki.lisp:1.3 Sat Jan 17 14:19:55 2004
+++ cl-irc/example/cliki.lisp Sun Feb 1 09:11:56 2004
@@ -1,4 +1,4 @@
-;;;; $Id: cliki.lisp,v 1.3 2004/01/17 19:19:55 bmastenbrook Exp $
+;;;; $Id: cliki.lisp,v 1.4 2004/02/01 14:11:56 bmastenbrook Exp $
;;;; $Source: /project/cl-irc/cvsroot/cl-irc/example/cliki.lisp,v $
;;;; cliki.lisp - CLiki as an infobot; only works on SBCL.
@@ -8,7 +8,8 @@
;;; "desiredserver" "#channel1" "#channel2" "#channel3" ...)
(defpackage :cliki (:use :common-lisp :irc :sb-bsd-sockets :cl-ppcre)
- (:export :start-cliki-bot))
+ (:export :start-cliki-bot :*cliki-nickserv-password*
+ :*respond-to-general-hellos*))
(in-package :cliki)
(defvar *small-definitions* nil)
@@ -133,7 +134,7 @@
(symbol-macrolet ((it ,test))
,else))))
-(defparameter *cliki-attention-prefix* "")
+(defparameter *cliki-attention-prefix* "^minion[,:]\\s+")
(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.")
@@ -170,23 +171,23 @@
))))))
(defun valid-cliki-message (message)
- (eql (search *cliki-attention-prefix* (trailing-argument message) :test #'char-equal) 0))
+ (scan *cliki-attention-prefix* (trailing-argument message)))
-(defparameter *respond-to-hello* nil)
+(defvar *respond-to-general-hellos* nil)
(defun anybody-here (string)
- (or (scan "(?i)(anybody|aynbody|any body|anyone|aynone|any one|ne1|any1|n e 1|ne 1) (here|awake|there|home|know).*\\?*" string)
- (scan "^(?i)\\s*(hello|hi|yo)\\s*(channel|room|people|ppl|all|peeps|)\\s*$" string)))
+ (if *respond-to-general-hellos*
+ (or (scan "(?i)(anybody|aynbody|any body|anyone|aynone|any one|ne1|any1|n e 1|ne 1) (here|awake|there|home|know).*\\?*" string)
+ (scan "^(?i)\\s*(hello|hi|yo)\\s*(channel|room|people|ppl|all|peeps|)\\s*$" string))))
(defun msg-hook (message)
- (if (string-equal (first (arguments message)) *cliki-nickname*)
- (if (valid-cliki-message message)
- (privmsg *cliki-connection* (source message) (cliki-lookup (subseq (trailing-argument message) (length *cliki-attention-prefix*))))
- (privmsg *cliki-connection* (source message) (cliki-lookup (trailing-argument 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* (first (arguments message)) (cliki-lookup (subseq (trailing-argument message) (length *cliki-attention-prefix*))))
- (if (and *respond-to-hello* (anybody-here (trailing-argument message)))
- (privmsg *cliki-connection* (first (arguments message)) (format nil "~A: hello." (source message)))))))
+ (privmsg *cliki-connection* respond-to (cliki-lookup (regex-replace *cliki-attention-prefix* (trailing-argument message) "")))
+ (if (string-equal (first (arguments message)) *cliki-nickname*)
+ (privmsg *cliki-connection* respond-to (cliki-lookup (trailing-argument message)))
+ (if (anybody-here (trailing-argument message))
+ (privmsg *cliki-connection* (first (arguments message)) (format nil "~A: hello." (source message))))))))
(defvar *cliki-nickserv-password* "")
@@ -198,7 +199,6 @@
(defun start-cliki-bot (nick server &rest channels)
(read-small-definitions)
(setf *cliki-nickname* nick)
- (setf *cliki-attention-prefix* (format nil "~A: " nick))
(setf *cliki-connection* (connect :nickname *cliki-nickname* :server server))
(mapcar #'(lambda (channel) (join *cliki-connection* channel)) channels)
(add-hook *cliki-connection* 'irc::irc-privmsg-message 'msg-hook)
Index: cl-irc/example/eliza-rules.lisp
diff -u cl-irc/example/eliza-rules.lisp:1.1 cl-irc/example/eliza-rules.lisp:1.2
--- cl-irc/example/eliza-rules.lisp:1.1 Sat Jan 17 14:19:55 2004
+++ cl-irc/example/eliza-rules.lisp Sun Feb 1 09:11:56 2004
@@ -168,6 +168,12 @@
((what (?* ?x) your (?* ?y) about chandler (?* ?z))
(He never tells me anything - what ?x your ?y about my creator ?z))
+ ((who (?* ?x) is chandler (?* ?y))
+ (chandler is my master))
+
+ ((who (?* ?x) your master (?* ?y))
+ (chandler is my master))
+
((what (?* ?x) you (?* ?y) about (?* ?z))
(I know nothing about ?z - what ?x you ?y about ?z))
((what (?* ?x) your (?* ?y) about (?* ?z))
@@ -392,8 +398,6 @@
(((?* ?x))
(you speak nonsense)
- (ich kann kein englisch)
- (whoop! my pants are on fire!)
- (look! behind you! superman!)
- (watch out or |I'll| capture you in a closure)
- (there must be methods of torture for people like you))))
\ No newline at end of file
+ (does torturing a poor bot with things beyond its comprehension please you?)
+ (please stop playing with |me...| I am not a toy)
+ (watch |out,| |you'll| make Krystof angry))))
\ No newline at end of file