Support for server->client PRIVMSG, JOIN

This commit is contained in:
Jaidyn Ann 2023-01-11 16:40:29 -06:00
parent 77782c380c
commit 7803e352a4

View File

@ -78,7 +78,7 @@
(cons 'user (user-alist conn user)) (cons 'user (user-alist conn user))
#f) #f)
(if channel (if channel
(if (get-keyword #:channel-long args) (if (get-keyword #:long-channel args)
(cons 'channel (channel-alist conn channel)) (cons 'channel (channel-alist conn channel))
(cons 'channel (channel-alist-short conn channel))) (cons 'channel (channel-alist-short conn channel)))
#f))))) #f)))))
@ -87,11 +87,15 @@
;; Hook function for irc:loop; handles all IRC commands ;; Hook function for irc:loop; handles all IRC commands
(define (on-command conn cmd params #!optional sender) (define (on-command conn cmd params #!optional sender)
(cond (cond
([string=? cmd "PRIVMSG"] [(string=? cmd "PRIVMSG")
(let ([msg (last params)] (json-write
[channel (first params)] (compose-event-alist conn "message" #:channel (car params)
[user (irc:hostmask-nick sender)]) #:text (last params) #:user (irc:hostmask-nick sender)))]
(json-write (compose-event-alist conn "message" #:content msg #:user user #:channel channel))))) [(string=? cmd "JOIN")
(json-write
(compose-event-alist conn "room-join" #:channel (car params)
#:user (irc:hostmask-nick sender)))])
(print sender ":" cmd params)) (print sender ":" cmd params))
@ -103,10 +107,8 @@
(irc:write-cmd conn "JOIN" "#thevoid")] (irc:write-cmd conn "JOIN" "#thevoid")]
[(or (eq? reply RPL_TOPIC) [(or (eq? reply RPL_TOPIC)
(eq? reply RPL_ENDOFWHO)) (eq? reply RPL_ENDOFWHO))
(let* ([channel (second params)] (json-write
[alist (compose-event-alist conn "room-info" #:channel channel #:long-channel #t)]) (compose-event-alist conn "room-info" #:channel (second params) #:long-channel #t))]))
(pretty-print alist)
(json-write alist))]))
(define *help-msg* (define *help-msg*