r8348: add nickserv identity password reply
authorKevin M. Rosenberg <kevin@rosenberg.net>
Wed, 17 Dec 2003 00:02:57 +0000 (00:02 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Wed, 17 Dec 2003 00:02:57 +0000 (00:02 +0000)
debian/changelog
logger.lisp

index 3f008d55ac41a0bde5b4ce2d03172bf7055c59ca..d4263769d4a9f68bbce01d688ab9af5437933c36 100644 (file)
@@ -1,3 +1,9 @@
+cl-irc-logger (0.3-1) unstable; urgency=low
+
+  * New upstream
+
+ -- Kevin M. Rosenberg <kmr@debian.org>  Tue, 16 Dec 2003 17:02:35 -0700
+
 cl-irc-logger (0.2-1) unstable; urgency=low
 
   * Initial upload
index e0da56a665a345e32f28c42b6f7aba33eb884d22..a1b8f5b2be15b62d2dcce262d8ff7c9674a63068 100644 (file)
@@ -20,6 +20,8 @@
               :documentation "IRC connection object.")
    (nick :initarg :nick :reader nickname
         :documentation "Nickname of the bot.")
+   (password :initarg :password :reader password
+            :documentation "Nickname's nickserver password.")
    (server :initarg :server :reader server
           :documentation "Connected IRC server.")
    (channels :initarg :channels :reader channels
@@ -45,6 +47,9 @@
 (defun find-logger-with-nick (nick)
   (find nick (the list *loggers*) :test #'string-equal :key #'nickname))
 
+(defun find-logger-with-connection (conn)
+  (find conn (the list *loggers*) :test #'eq :key #'connection))
+
 (defun make-output-name (name year month day)
     (format nil "~A-~4,'0D.~2,'0D.~2,'0D"
            (string-left-trim '(#\#) name) year month day))
   (output-event msg :kick (first (arguments msg))))
 
 (defun notice-hook (msg)
-  (output-event msg :notice (first (arguments msg)) (trailing-argument msg)))
+  (if (and (string-equal (source msg) "NickServ")
+          (string-equal "owned by someone else" (trailing-argument msg)))
+      (let ((logger (find-logger-with-connection (connection msg))))
+       (if logger
+           (privmsg (connection msg) (source msg) (format nil "IDENTIFY ~A" (password logger)))
+           (warn "NickServ asks for identity with connection not found."))) 
+      (output-event msg :notice (first (arguments msg)) (trailing-argument msg))))
 
 (defun topic-hook (msg)
   (output-event msg :topic (first (arguments msg)) (trailing-argument msg)))
   "Returns T if output is setup for a single channel directory structure."
   (and (pathnamep user-output) (null (pathname-name user-output))))
                  
-(defun create-logger (nick server &key channels output
-                     (logging-stream t)
-                     (formats '(:text)))
+(defun create-logger (nick server &key channels output password
+                     (logging-stream t) (formats '(:text)))
   "OUTPUT may be a pathname or a stream"
   ;; check arguments
   (assert channels)
                  'logger
                  :connection conn
                  :nick nick
+                 :password password
                  :server server
                  :channels (make-channels channels formats output)
                  :user-output output
 
 (defun start-logger (logger async)
   (if async
-      (read-message-loop-background (connection logger))
-    (read-message-loop (connection logger))))
+      (start-background-message-handler (connection logger))
+      (read-message-loop (connection logger))))
 
 (defun quit-logger (nick)
   "Quit the active connection with nick and remove from active list."
             (delete nick *loggers*  :test #'string-equal :key #'nickname))
        t))))
 
-(defun add-logger (nick server &key channels output
-                  (logging-stream t)
-                  (async t)
-                  (formats '(:text)))
+(defun add-logger (nick server &key channels output (password "")
+                  (logging-stream t) (async t) (formats '(:text)))
   (when (find-logger-with-nick nick)
     (warn "Closing previously active connection.")
     (quit-logger nick))
   (let ((logger (create-logger nick server :channels channels :output output
-                              :logging-stream logging-stream
+                              :logging-stream logging-stream :password password
                               :formats formats)))
     (push logger *loggers*)
     (start-logger logger async)