Make reply-function a bit more readable
This commit is contained in:
parent
325e94dbdd
commit
82599798fc
|
@ -21,7 +21,7 @@
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(import scheme
|
(import scheme
|
||||||
(chicken file) (chicken io) (chicken pathname)
|
(chicken file) (chicken file posix) (chicken io) (chicken pathname)
|
||||||
(chicken process-context) (chicken process-context posix)
|
(chicken process-context) (chicken process-context posix)
|
||||||
(chicken string)
|
(chicken string)
|
||||||
srfi-1 srfi-18 srfi-69
|
srfi-1 srfi-18 srfi-69
|
||||||
|
@ -95,16 +95,17 @@
|
||||||
(define (make-irc-reply-callback conn)
|
(define (make-irc-reply-callback conn)
|
||||||
(let ([root-dir (hash-table-ref conn 'directory)])
|
(let ([root-dir (hash-table-ref conn 'directory)])
|
||||||
(lambda (conn reply params #!optional sender)
|
(lambda (conn reply params #!optional sender)
|
||||||
|
(let ([channel (second params)])
|
||||||
(cond
|
(cond
|
||||||
;; If topic set, output to a channel's .topic file
|
;; If topic set, output to a channel's .topic file
|
||||||
[(and (eq? reply RPL_TOPIC)
|
[(and (eq? reply RPL_TOPIC)
|
||||||
(irc:channel? (second params)))
|
(irc:channel? channel))
|
||||||
(chatdir:channel-metadata-set! root-dir (second params)
|
(chatdir:channel-metadata-set! root-dir channel
|
||||||
"topic" (last params))]
|
"topic" (last params))]
|
||||||
|
|
||||||
[(and (eq? reply RPL_TOPICWHOTIME)
|
[(and (eq? reply RPL_TOPICWHOTIME)
|
||||||
(irc:channel? (second params)))
|
(irc:channel? (second params)))
|
||||||
(chatdir:channel-metadata-set! root-dir (second params)
|
(chatdir:channel-metadata-set! root-dir channel
|
||||||
"topic" #f
|
"topic" #f
|
||||||
`((user.chat.sender . ,(third params))
|
`((user.chat.sender . ,(third params))
|
||||||
(user.chat.date . ,(last params))))]
|
(user.chat.date . ,(last params))))]
|
||||||
|
@ -114,15 +115,13 @@
|
||||||
(eq? reply RPL_ENDOFNAMES))
|
(eq? reply RPL_ENDOFNAMES))
|
||||||
(eq? reply RPL_ENDOFWHO))
|
(eq? reply RPL_ENDOFWHO))
|
||||||
(map (lambda (nick)
|
(map (lambda (nick)
|
||||||
(let ([hostmask (irc:user-get conn nick 'hostmask)]
|
(let ([hostmask (irc:user-get conn nick 'hostmask)])
|
||||||
[channel (second params)])
|
|
||||||
(chatdir:channel-user-add! root-dir channel nick)
|
(chatdir:channel-user-add! root-dir channel nick)
|
||||||
(chatdir:channel-user-toggle-states! root-dir channel nick
|
(chatdir:channel-user-toggle-states! root-dir channel nick
|
||||||
"online" "offline")))
|
"online" "offline")))
|
||||||
(irc:channel-users conn (second params)))]
|
(irc:channel-users conn (second params)))]
|
||||||
|
[(string? (last params))
|
||||||
[#t
|
(chatdir:channel-message-add! root-dir ".server" (last params))])))))
|
||||||
(chatdir:channel-message-add! root-dir ".server" (last params) "server")]))))
|
|
||||||
|
|
||||||
|
|
||||||
(define *help-msg*
|
(define *help-msg*
|
||||||
|
@ -226,7 +225,7 @@
|
||||||
;; Kick off the main loop!
|
;; Kick off the main loop!
|
||||||
(irc:loop connection
|
(irc:loop connection
|
||||||
(make-irc-command-callback connection)
|
(make-irc-command-callback connection)
|
||||||
(make-irc-reply-callback connection)))))
|
(make-irc-reply-callback connection))))
|
||||||
|
|
||||||
|
|
||||||
(main)
|
(main)
|
||||||
|
|
Reference in New Issue