1
0
Disbranĉigi 0

Make reply-function a bit more readable

This commit is contained in:
Jaidyn Ann 2023-05-29 11:00:52 -05:00
parent 325e94dbdd
commit 82599798fc

View File

@ -21,7 +21,7 @@
;;
(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 string)
srfi-1 srfi-18 srfi-69
@ -95,16 +95,17 @@
(define (make-irc-reply-callback conn)
(let ([root-dir (hash-table-ref conn 'directory)])
(lambda (conn reply params #!optional sender)
(let ([channel (second params)])
(cond
;; If topic set, output to a channel's .topic file
[(and (eq? reply RPL_TOPIC)
(irc:channel? (second params)))
(chatdir:channel-metadata-set! root-dir (second params)
(irc:channel? channel))
(chatdir:channel-metadata-set! root-dir channel
"topic" (last params))]
[(and (eq? reply RPL_TOPICWHOTIME)
(irc:channel? (second params)))
(chatdir:channel-metadata-set! root-dir (second params)
(chatdir:channel-metadata-set! root-dir channel
"topic" #f
`((user.chat.sender . ,(third params))
(user.chat.date . ,(last params))))]
@ -114,15 +115,13 @@
(eq? reply RPL_ENDOFNAMES))
(eq? reply RPL_ENDOFWHO))
(map (lambda (nick)
(let ([hostmask (irc:user-get conn nick 'hostmask)]
[channel (second params)])
(let ([hostmask (irc:user-get conn nick 'hostmask)])
(chatdir:channel-user-add! root-dir channel nick)
(chatdir:channel-user-toggle-states! root-dir channel nick
"online" "offline")))
(irc:channel-users conn (second params)))]
[#t
(chatdir:channel-message-add! root-dir ".server" (last params) "server")]))))
[(string? (last params))
(chatdir:channel-message-add! root-dir ".server" (last params))])))))
(define *help-msg*
@ -226,7 +225,7 @@
;; Kick off the main loop!
(irc:loop connection
(make-irc-command-callback connection)
(make-irc-reply-callback connection)))))
(make-irc-reply-callback connection))))
(main)