Remove some IRC-related functions
This commit is contained in:
parent
abfd96998e
commit
13f9738ca9
76
chatdir.scm
76
chatdir.scm
|
@ -131,82 +131,6 @@
|
|||
(user-enable-state conn channel hostmask enabled-state))
|
||||
|
||||
|
||||
;; Sets a channel's .topic file
|
||||
(define (set-channel-topic conn channel topic #!optional (username #f) (date #f))
|
||||
(let ([topic-path (string-append (channel-directory-path conn channel)
|
||||
".topic")])
|
||||
(if (string? topic)
|
||||
(call-with-output-file
|
||||
topic-path
|
||||
(lambda (out-port)
|
||||
(write-string topic #f out-port))))
|
||||
(if username
|
||||
(set-xattr topic-path "user.chat.sender" (irc:hostmask-nick username)))))
|
||||
|
||||
|
||||
;; Send message to an IRC channel
|
||||
(define (send-message connection channel message)
|
||||
(irc:write-cmd connection "PRIVMSG" channel message)
|
||||
(make-message-file connection channel
|
||||
(hash-table-ref connection 'nick)
|
||||
message))
|
||||
|
||||
|
||||
;; Hook function for irc:loop; handles all IRC commands
|
||||
(define (on-command conn cmd params #!optional sender)
|
||||
(cond
|
||||
[(and (string=? cmd "PRIVMSG")
|
||||
(string? sender)
|
||||
(irc:hostmask? sender))
|
||||
(let ([target (if (irc:user-is-self? conn (car params))
|
||||
(irc:hostmask-nick sender)
|
||||
(car params))])
|
||||
(make-message-file conn target (irc:hostmask-nick sender) (last params)))]
|
||||
|
||||
[(or (string=? cmd "NOTICE")
|
||||
(and (string=? cmd "PRIVMSG")
|
||||
(or (string-null? sender) (not (irc:hostmask? sender)))))
|
||||
(make-message-file conn ".server" "server" (last params))]
|
||||
|
||||
[(and (string=? cmd "JOIN") (irc:user-is-self? conn sender))
|
||||
(make-channel conn (last params))]
|
||||
|
||||
[(string=? cmd "JOIN")
|
||||
(make-user conn (last params) sender)]
|
||||
|
||||
;; [(string=? cmd "NICK")
|
||||
;; (chatd-json-write conn
|
||||
;; (compose-event-alist conn "user-info" #:user (last params)))])
|
||||
))
|
||||
|
||||
|
||||
;; Hook function for irc:loop; handles all IRC errors and replies
|
||||
(define (on-reply conn reply params #!optional sender)
|
||||
(cond
|
||||
;; If topic set, output to a channel's .topic file
|
||||
[(and (eq? reply RPL_TOPIC)
|
||||
(irc:channel? (second params)))
|
||||
(set-channel-topic conn (second params) (last params))]
|
||||
|
||||
[(and (eq? reply RPL_TOPICWHOTIME)
|
||||
(irc:channel? (second params)))
|
||||
(set-channel-topic conn (second params) #f (third params) (last params))]
|
||||
|
||||
;; We've got to add users, when they join the room!
|
||||
[(or (and (irc:capability? conn 'userhost-in-names)
|
||||
(eq? reply RPL_ENDOFNAMES))
|
||||
(eq? reply RPL_ENDOFWHO))
|
||||
(map (lambda (nick)
|
||||
(let ([hostmask (irc:user-get conn nick 'hostmask)]
|
||||
[channel (second params)])
|
||||
(make-user conn channel hostmask)
|
||||
(user-toggle-state conn channel hostmask "online" "offline")))
|
||||
(irc:channel-users conn (second params)))]
|
||||
|
||||
[#t
|
||||
(make-message-file conn ".server" "server" (last params))]))
|
||||
|
||||
|
||||
(define (write-string-to-file file value)
|
||||
(call-with-output-file file
|
||||
(lambda (out-port)
|
||||
|
|
Reference in New Issue