easier passing in of line handler things
authorChristopher Allan Webber <cwebber@dustycloud.org>
Mon, 23 Nov 2015 22:10:54 +0000 (16:10 -0600)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Mon, 23 Nov 2015 22:10:54 +0000 (16:10 -0600)
eightsync/systems/irc.scm

index a802167726ba8805967aa53a4864624b6eeeaae5..bf450b94efc526ef680e9472c7804438b5386ee9 100755 (executable)
           (_ #f))))
     irc-handler))
 
+(define default-line-handler (make-handle-line))
 
 (define* (queue-and-start-irc-agenda! agenda socket #:key
                                       (username "syncbot")
                                       (inet-port default-irc-port)
-                                      (handler (make-basic-irc-handler
-                                                (lambda args
-                                                  (apply (make-handle-line) args))
-                                                username))
+                                      (line-handler default-line-handler)
                                       (channels '()))
   (dynamic-wind
     (lambda () #f)
     (lambda ()
-      (enq! (agenda-queue agenda) (wrap (install-socket socket handler)))
+      (enq! (agenda-queue agenda)
+            (wrap (install-socket
+                   socket
+                   (make-basic-irc-handler
+                    line-handler
+                    username))))
       (enq! (agenda-queue agenda) (wrap (handle-login socket username
                                                       #:channels channels)))
       (start-agenda agenda))
     (channels (value #t))
     (listen)))
 
-(define* (make-irc-bot-cli)
+(define* (make-irc-bot-cli #:optional (line-handler default-line-handler))
   (define (main args)
     (let* ((options (getopt-long args option-spec))
            (hostname (option-ref options 'server #f))
        (irc-socket-setup hostname port)
        #:inet-port port
        #:username username
-       #:channels (string-split channels #\space))))
+       #:channels (string-split channels #\space)
+       #:line-handler line-handler)))
   main)
 
 (define main (make-irc-bot-cli))