[cl-irc-devel] trailing argument bots patch

Erik Huelsmann e.huelsmann at gmx.net
Mon Feb 20 20:47:41 UTC 2006


Hi!

Deprecating trailing-argument makes the bots in examples/ out of date.

Below is a patch to fix that, but, given that I don't run them much, I'd
like to send the patch here and have someone look them over and commit.
Brian, could you?

Thanks in advance!

bye,


Erik.



Index: example/cliki.lisp
===================================================================
RCS file: /project/cl-irc/cvsroot/cl-irc/example/cliki.lisp,v
retrieving revision 1.38
diff -u -r1.38 cliki.lisp
--- example/cliki.lisp	15 Oct 2005 19:16:52 -0000	1.38
+++ example/cliki.lisp	20 Feb 2006 20:36:21 -0000
@@ -723,7 +723,7 @@
 
 
 (defun valid-cliki-message (message)
-  (scan *cliki-attention-prefix* (trailing-argument message)))
+  (scan *cliki-attention-prefix* (car (last (arguments message)))))
 
 (defvar *respond-to-general-hellos* nil)
 
@@ -740,24 +740,27 @@
 	 (format *trace-output* "~A~%"
 		 (nthcdr 10 (sb-debug:backtrace-as-list)))
 	 (return-from msg-hook))))
-    (progn
-      (scan-for-more (trailing-argument message))
-      (let ((respond-to (if (string-equal (first (arguments message))
*cliki-nickname*) (source message) (first (arguments message)))))
+    (destructuring-arguments
+        (target &rest unused &last text)
+        message
+      (declare (ignore unused))
+      (scan-for-more text)
+      (let ((respond-to (if (string-equal target *cliki-nickname*) (source
message) target)))
 	(if (valid-cliki-message message)
-	    (let ((response (cliki-lookup (regex-replace *cliki-attention-prefix*
(trailing-argument message) "") :sender (source message) :channel (first
(irc:arguments message)))))
+	    (let ((response (cliki-lookup (regex-replace *cliki-attention-prefix*
text "") :sender (source message) :channel target)))
 	      (and response (privmsg *cliki-connection* respond-to response)))
-	    (if (string-equal (first (arguments message)) *cliki-nickname*)
-		(aif (cliki-lookup (trailing-argument message) :sender (source message))
+	    (if (string-equal target *cliki-nickname*)
+		(aif (cliki-lookup text :sender (source message))
 		     (privmsg *cliki-connection* respond-to it))
-		(if (anybody-here (trailing-argument message))
-		    (privmsg *cliki-connection* (first (arguments message)) (format nil
"~A: hello." (source message))))))
+		(if (anybody-here text)
+		    (privmsg *cliki-connection* target (format nil "~A: hello." (source
message))))))
 	(take-care-of-memos respond-to (source message))))))
 
 (defvar *cliki-nickserv-password* "")
 
 (defun notice-hook (message)
   (if (and (string-equal (source message) "NickServ")
-	   (scan "owned by someone else" (trailing-argument message)))
+	   (scan "owned by someone else" (car (last (arguments message)))))
       (privmsg *cliki-connection* (source message) (format nil "IDENTIFY
~A" *cliki-nickserv-password*))))
 
 (defun rename-cliki (new-nick)
Index: example/specbot.lisp
===================================================================
RCS file: /project/cl-irc/cvsroot/cl-irc/example/specbot.lisp,v
retrieving revision 1.14
diff -u -r1.14 specbot.lisp
--- example/specbot.lisp	9 Aug 2005 01:26:14 -0000	1.14
+++ example/specbot.lisp	20 Feb 2006 20:36:21 -0000
@@ -102,12 +102,13 @@
   (and (not final) string))
 
 (defun msg-hook (message)
-  (let ((destination (if (string-equal (first (arguments message))
*nickname*)
-                         (source message)
-                         (first (arguments message))))
+  (let* ((target (first (arguments message))))
+         (destination (if (string-equal target *nickname*)
+                          (source message)
+                        target))
         (to-lookup (strip-address (trailing-argument message))))
     (if (and (or
-              (string-equal (first (arguments message)) *nickname*)
+              (string-equal target *nickname*)
               (not (string= to-lookup (trailing-argument message))))
              (member to-lookup '("help" "help?") :test #'string-equal))
         (progn


-- 
DSL-Aktion wegen großer Nachfrage bis 28.2.2006 verlängert:
GMX DSL-Flatrate 1 Jahr kostenlos* http://www.gmx.net/de/go/dsl



More information about the cl-irc-devel mailing list