Update of /project/net-nittin-irc/cvsroot/net-nittin-irc In directory common-lisp.net:/tmp/cvs-serv11001
Modified Files: README command.lisp event.lisp net-nittin-irc.asd package.lisp parse-message.lisp protocol.lisp utility.lisp Log Message: removing configuration details
removing unused irc-message-event methods
some renamings
Date: Sun Nov 23 17:39:17 2003 Author: eenge
Index: net-nittin-irc/README diff -u net-nittin-irc/README:1.3 net-nittin-irc/README:1.4 --- net-nittin-irc/README:1.3 Mon Nov 3 17:22:18 2003 +++ net-nittin-irc/README Sun Nov 23 17:39:15 2003 @@ -1,5 +1,5 @@ net-nittin-irc: A Common Lisp interface to the client-part of the IRC -protocol. +protocol; RFCs 2810, 2811 and 2812.
Quick demo:
Index: net-nittin-irc/command.lisp diff -u net-nittin-irc/command.lisp:1.6 net-nittin-irc/command.lisp:1.7 --- net-nittin-irc/command.lisp:1.6 Fri Nov 14 15:35:01 2003 +++ net-nittin-irc/command.lisp Sun Nov 23 17:39:15 2003 @@ -1,4 +1,4 @@ -;;;; $Id: command.lisp,v 1.6 2003/11/14 20:35:01 bmastenbrook Exp $ +;;;; $Id: command.lisp,v 1.7 2003/11/23 22:39:15 eenge Exp $ ;;;; $Source: /project/net-nittin-irc/cvsroot/net-nittin-irc/command.lisp,v $
;;;; See LICENSE for licensing information. @@ -6,6 +6,21 @@ (in-package :irc)
(defmethod pass ((connection connection) (password string)) + "A "PASS" command is not required for a client connection to be +registered, but it MUST precede the latter of the NICK/USER +combination (for a user connection) or the SERVICE command (for a +service connection). The RECOMMENDED order for a client to register is +as follows: + + 1. Pass message + 2. Nick message 2. Service message + 3. User message + +Upon success, the client will receive an RPL_WELCOME (for users) or +RPL_YOURESERVICE (for services) message indicating that the connection +is now registered and known the to the entire IRC network. The reply +message MUST contain the full client identifier upon which it was +registered." (send-irc-message connection :pass nil password))
(defmethod nick ((connection connection) (new-nickname string))
Index: net-nittin-irc/event.lisp diff -u net-nittin-irc/event.lisp:1.8 net-nittin-irc/event.lisp:1.9 --- net-nittin-irc/event.lisp:1.8 Sat Nov 22 13:55:53 2003 +++ net-nittin-irc/event.lisp Sun Nov 23 17:39:15 2003 @@ -1,4 +1,4 @@ -;;;; $Id: event.lisp,v 1.8 2003/11/22 18:55:53 eenge Exp $ +;;;; $Id: event.lisp,v 1.9 2003/11/23 22:39:15 eenge Exp $ ;;;; $Source: /project/net-nittin-irc/cvsroot/net-nittin-irc/event.lisp,v $
;;;; See LICENSE for licensing information. @@ -191,31 +191,31 @@
(defmethod irc-message-event ((message ctcp-dcc-chat-request-message)) (apply-to-hooks message) - (client-log (connection message) message) - (when (automatically-accept-dcc-connections (configuration (connection message))) - (let* ((user (find-user (connection message) (source message))) - (args (tokenize-string (trailing-argument message))) - (remote-address (hbo-to-vector-quad (parse-integer (fourth args)))) - (remote-port (parse-integer (fifth args) :junk-allowed t))) - (push (make-dcc-connection :user user - :remote-address remote-address - :remote-port remote-port) - *dcc-connections*)))) + (client-log (connection message) message)) +; (when (automatically-accept-dcc-connections (configuration (connection message))) +; (let* ((user (find-user (connection message) (source message))) +; (args (tokenize-string (trailing-argument message))) +; (remote-address (hbo-to-vector-quad (parse-integer (fourth args)))) +; (remote-port (parse-integer (fifth args) :junk-allowed t))) +; (push (make-dcc-connection :user user +; :remote-address remote-address +; :remote-port remote-port) +; *dcc-connections*))))
(defmethod irc-message-event ((message ctcp-dcc-send-request-message)) (apply-to-hooks message) - (client-log (connection message) message) - (when (automatically-accept-dcc-downloads (configuration (connection message))) - (let* ((user (find-user (connection message) (source message))) - (args (tokenize-string (trailing-argument message))) - (filename (third args)) - (remote-address (hbo-to-vector-quad (parse-integer (fourth args)))) - (remote-port (parse-integer (fifth args))) - (filesize (parse-integer (sixth args) :junk-allowed t))) - (let ((dcc-connection (make-dcc-connection :user user - :remote-address remote-address - :remote-port remote-port))) - (with-open-file (stream filename :direction :output - :if-exists :supersede) - (write-sequence (read-message-loop dcc-connection) stream)))))) + (client-log (connection message) message)) +; (when (automatically-accept-dcc-downloads (configuration (connection message))) +; (let* ((user (find-user (connection message) (source message))) +; (args (tokenize-string (trailing-argument message))) +; (filename (third args)) +; (remote-address (hbo-to-vector-quad (parse-integer (fourth args)))) +; (remote-port (parse-integer (fifth args))) +; (filesize (parse-integer (sixth args) :junk-allowed t))) +; (let ((dcc-connection (make-dcc-connection :user user +; :remote-address remote-address +; :remote-port remote-port))) +; (with-open-file (stream filename :direction :output +; :if-exists :supersede) +; (write-sequence (read-message-loop dcc-connection) stream))))))
Index: net-nittin-irc/net-nittin-irc.asd diff -u net-nittin-irc/net-nittin-irc.asd:1.3 net-nittin-irc/net-nittin-irc.asd:1.4 --- net-nittin-irc/net-nittin-irc.asd:1.3 Sat Nov 22 13:57:14 2003 +++ net-nittin-irc/net-nittin-irc.asd Sun Nov 23 17:39:16 2003 @@ -1,4 +1,4 @@ -;;;; $Id: net-nittin-irc.asd,v 1.3 2003/11/22 18:57:14 eenge Exp $ +;;;; $Id: net-nittin-irc.asd,v 1.4 2003/11/23 22:39:16 eenge Exp $ ;;;; $Source: /project/net-nittin-irc/cvsroot/net-nittin-irc/net-nittin-irc.asd,v $
;;;; See the LICENSE file for licensing information. @@ -16,10 +16,12 @@ :version "0.1.0" :licence "MIT" :description "Common Lisp interface to the IRC protocol" - #+sbcl :depends-on (:sb-bsd-sockets :split-sequence) + :depends-on + #+sbcl (:sb-bsd-sockets :split-sequence) + #-sbcl (:split-sequence) :depends-on (:split-sequence) :properties ((#:author-email . "net-nittin-irc-devel@common-lisp.net") - (#:date . "$Date: 2003/11/22 18:57:14 $") + (#:date . "$Date: 2003/11/23 22:39:16 $") ((#:albert #:output-dir) . "doc/api-doc/") ((#:albert #:formats) . ("docbook")) ((#:albert #:docbook #:template) . "book") @@ -38,5 +40,3 @@ :depends-on ("protocol")) (:file "event" :depends-on ("command")))) - -
Index: net-nittin-irc/package.lisp diff -u net-nittin-irc/package.lisp:1.8 net-nittin-irc/package.lisp:1.9 --- net-nittin-irc/package.lisp:1.8 Fri Nov 14 15:35:01 2003 +++ net-nittin-irc/package.lisp Sun Nov 23 17:39:16 2003 @@ -1,4 +1,4 @@ -;;;; $Id: package.lisp,v 1.8 2003/11/14 20:35:01 bmastenbrook Exp $ +;;;; $Id: package.lisp,v 1.9 2003/11/23 22:39:16 eenge Exp $ ;;;; $Source: /project/net-nittin-irc/cvsroot/net-nittin-irc/package.lisp,v $
;;;; See the LICENSE file for licensing information. @@ -14,6 +14,7 @@ :add-asynchronous-message-handler :send-message :server-name + :no-such-reply :server-stream :client-stream :channels @@ -42,6 +43,7 @@ :make-channel :client-log :find-channel + :find-reply-name :remove-channel :remove-all-channels :add-channel
Index: net-nittin-irc/parse-message.lisp diff -u net-nittin-irc/parse-message.lisp:1.5 net-nittin-irc/parse-message.lisp:1.6 --- net-nittin-irc/parse-message.lisp:1.5 Sat Nov 22 14:21:33 2003 +++ net-nittin-irc/parse-message.lisp Sun Nov 23 17:39:16 2003 @@ -1,4 +1,4 @@ -;;;; $Id: parse-message.lisp,v 1.5 2003/11/22 19:21:33 eenge Exp $ +;;;; $Id: parse-message.lisp,v 1.6 2003/11/23 22:39:16 eenge Exp $ ;;;; $Source: /project/net-nittin-irc/cvsroot/net-nittin-irc/parse-message.lisp,v $
;;;; See the LICENSE file for licensing information. @@ -119,7 +119,7 @@ :dcc-send-request)) (otherwise nil)))
-(defun ctcp-message-p (string) +(defun ctcp-message-type (string) "If `string' is a CTCP message, return the type of the message or nil if this is a) not a CTCP message or b) a CTCP message we don't know about."
Index: net-nittin-irc/protocol.lisp diff -u net-nittin-irc/protocol.lisp:1.13 net-nittin-irc/protocol.lisp:1.14 --- net-nittin-irc/protocol.lisp:1.13 Sat Nov 22 14:24:13 2003 +++ net-nittin-irc/protocol.lisp Sun Nov 23 17:39:16 2003 @@ -1,4 +1,4 @@ -;;;; $Id: protocol.lisp,v 1.13 2003/11/22 19:24:13 eenge Exp $ +;;;; $Id: protocol.lisp,v 1.14 2003/11/23 22:39:16 eenge Exp $ ;;;; $Source: /project/net-nittin-irc/cvsroot/net-nittin-irc/protocol.lisp,v $
;;;; See LICENSE for licensing information. @@ -56,11 +56,6 @@ :initarg :hooks :accessor hooks :initform (make-hash-table :test #'equal)) - (configuration - :initarg :configuration - :accessor configuration - :documentation "A CONFIGURATION object which would dictate much of -the behaviour of the library towards the connection object.") (dangling-users :initarg :dangling-users :accessor dangling-users @@ -82,20 +77,16 @@ (channels nil) (dangling-users nil) (hooks nil) - (channel-list nil) - (configuration nil)) - (let* ((configuration (or configuration - (make-configuration))) - (connection (make-instance 'connection - :user user - :server-name server-name - :server-socket server-socket - :server-stream server-stream - :client-stream client-stream - :channels channels - :dangling-users dangling-users - :channel-list channel-list - :configuration configuration))) + (channel-list nil)) + (let ((connection (make-instance 'connection + :user user + :server-name server-name + :server-socket server-socket + :server-stream server-stream + :client-stream client-stream + :channels channels + :dangling-users dangling-users + :channel-list channel-list))) (dolist (hook hooks) (add-hook connection (car hook) (cadr hook))) connection)) @@ -183,33 +174,6 @@
(defmethod remove-hooks ((connection connection) class) (setf (gethash class (hooks connection)) nil)) - -;; -;; Configuration -;; - -(defclass configuration () - ((automatically-accept-dcc-connections - :initarg :automatically-accept-dcc-connections - :accessor automatically-accept-dcc-connections - :initform t) - (automatically-accept-dcc-downloads - :initarg :automatically-accept-dcc-downloads - :accessor automatically-accept-dcc-downloads - :initform t) - (dcc-download-directory - :initarg :dcc-download-directory - :accessor dcc-download-directory - :initform (user-homedir-pathname)))) - -(defun make-configuration (&key - (automatically-accept-dcc-connections t) - (automatically-accept-dcc-downloads t) - (dcc-download-directory (user-homedir-pathname))) - (make-instance 'configuration - :automatically-accept-dcc-connections automatically-accept-dcc-connections - :automatically-accept-dcc-downloads automatically-accept-dcc-downloads - :dcc-download-directory dcc-download-directory))
;; ;; DCC Connection
Index: net-nittin-irc/utility.lisp diff -u net-nittin-irc/utility.lisp:1.4 net-nittin-irc/utility.lisp:1.5 --- net-nittin-irc/utility.lisp:1.4 Sat Nov 22 14:07:16 2003 +++ net-nittin-irc/utility.lisp Sun Nov 23 17:39:16 2003 @@ -1,15 +1,10 @@ -;;;; $Id: utility.lisp,v 1.4 2003/11/22 19:07:16 eenge Exp $ +;;;; $Id: utility.lisp,v 1.5 2003/11/23 22:39:16 eenge Exp $ ;;;; $Source: /project/net-nittin-irc/cvsroot/net-nittin-irc/utility.lisp,v $
;;;; See the LICENSE file for licensing information.
(in-package :irc)
-(defun string-join (string1 string2) - (if (typep string2 'string) - (concatenate 'string string1 string2) - (concatenate 'string string1 (list string2)))) - (defun get-day-name (day-number) "Given a number, such as 1, return the appropriate day name, abbrevated, such as "Tue". Index 0 is Monday." @@ -43,6 +38,8 @@ (error "Unknown month ~A." month-number))))
(defun make-time-message (second minute hour date month year day) + "Returns a string composed of the input parameters so that it +represents a time message as by the IRC protocol." (format nil "~A ~A ~2D ~2,'0D:~2,'0D:~2,'0D ~D" (get-day-name day) (get-month-name month) @@ -52,21 +49,10 @@ second year))
-(defmacro with-output-as-irc-message ((sym stream message) &body body) - (let ((-second- (gensym)) - (-minute- (gensym)) - (-hour- (gensym)) - (-msg- (gensym))) - `(let ((,sym ,stream) - (,-msg- ,message)) - (multiple-value-bind (,-second- ,-minute- ,-hour-) - (decode-universal-time (receive-time ,-msg-)) - (format ,sym "[~2,'0D:~2,'0D:~2,'0D] " ,-hour- ,-minute- ,-second-) - ,@body) - (terpri ,sym)))) - (defun make-irc-message (command &key (arguments nil) (trailing-argument nil)) + "Return a valid IRC message, as a string, composed of the input +parameters." (format nil "~A~{ ~A~}~A~A~A~A" command arguments (if trailing-argument " :" @@ -75,12 +61,14 @@ #\Return #\Linefeed))
-(defun make-ctcp-message (message) - (format nil "~A~A~A" +soh+ message +soh+)) +(defun make-ctcp-message (string) + "Return a valid IRC CTCP message, as a string, composed by +`string'." + (format nil "~A~A~A" +soh+ string +soh+))
(defun tokenize-string (string &key (delimiters '(#\Space #\Return #\Linefeed #\Newline))) - "Split string into a list, splitting on delimiters and removing any + "Split string into a list, splitting on `delimiters' and removing any empty subsequences." (split-sequence:split-sequence-if #'(lambda (character) (member character delimiters))