(irc-format socket "JOIN ~a" channel))
channels))
-(define (handle-line socket line)
- (display line)
- (newline))
-
-(define (make-simple-irc-handler handle-line)
+(define (handle-line socket line my-username)
+ (match (string-split line #\space)
+ (("PING" rest ...)
+ (irc-display "PONG" socket)
+ (display "PONG'ed back ;)\n"))
+ (_
+ (display line)
+ (newline))))
+
+(define (make-simple-irc-handler handle-line username)
(let ((buffer '()))
(define (reset-buffer)
(set! buffer '()))
((#\newline #\return (? char? line-chars) ...)
(%sync (%run (handle-line
socket
- (list->string (reverse line-chars)))))
+ (list->string (reverse line-chars))
+ username)))
;; reset buffer
(set! buffer '()))
(_ #f))))
(define* (queue-and-start-irc-agenda! agenda socket #:key
(username "syncbot")
(inet-port default-irc-port)
- (handler (make-simple-irc-handler handle-line))
+ (handler (make-simple-irc-handler
+ (lambda args
+ (apply handle-line args))
+ username))
(channels '()))
(dynamic-wind
(lambda () #f)
(irc-socket-setup hostname port)
#:inet-port port
#:username username
- #:handler (make-simple-irc-handler handle-line)
#:channels (string-split channels #\space))))