irc.client: Calculate message forwards before processing it (because participants may be deleted from channels)

db4
Bruno Deferrari 2009-04-15 00:03:25 -03:00
parent 8f287b2c26
commit 777cb541f7
1 changed files with 11 additions and 8 deletions

View File

@ -45,11 +45,11 @@ M: sequence chat-put [ chat-put ] with each ;
! Server message handling ! Server message handling
GENERIC: forward-message ( irc-message -- ) GENERIC: message-forwards ( irc-message -- seq )
M: irc-message forward-message +server-chat+ chat-put ; M: irc-message message-forwards drop +server-chat+ ;
M: to-one-chat forward-message dup chat> chat-put ; M: to-one-chat message-forwards chat> ;
M: to-all-chats forward-message chats> chat-put ; M: to-all-chats message-forwards drop chats> ;
M: to-many-chats forward-message dup sender>> participant-chats chat-put ; M: to-many-chats message-forwards sender>> participant-chats ;
GENERIC: process-message ( irc-message -- ) GENERIC: process-message ( irc-message -- )
M: object process-message drop ; M: object process-message drop ;
@ -112,10 +112,13 @@ M: f handle-input handle-disconnect ;
! Processing loops ! Processing loops
! FIXME: should get forward channels, process the message, and then forward
: in-multiplexer-loop ( -- ? ) : in-multiplexer-loop ( -- ? )
irc> in-messages>> mailbox-get irc> in-messages>> mailbox-get {
[ forward-message ] [ process-message ] [ irc-end? not ] tri ; [ message-forwards ]
[ process-message ]
[ swap chat-put ]
[ irc-end? not ]
} cleave ;
: strings>privmsg ( name string -- privmsg ) : strings>privmsg ( name string -- privmsg )
" :" prepend append "PRIVMSG " prepend string>irc-message ; " :" prepend append "PRIVMSG " prepend string>irc-message ;