TUPLE: irc-client profile stream in-messages out-messages
chats is-running nick connect reconnect-time is-ready ;
+
: <irc-client> ( profile -- irc-client )
- [ f <mailbox> <mailbox> H{ } clone f ] keep nickname>>
- [ <inet> latin1 <client> ] 15 seconds f irc-client boa ;
+ irc-client new
+ swap >>profile
+ <mailbox> >>in-messages
+ <mailbox> >>out-messages
+ H{ } clone >>chats
+ dup profile>> nickname>> >>nick
+ [ <inet> latin1 <client> ] >>connect
+ 15 seconds >>reconnect-time ;
TUPLE: irc-chat in-messages client ;
TUPLE: irc-server-chat < irc-chat ;
: change-participant-mode ( channel mode nick -- )
rot chat>
[ participants>> set-at ]
- [ [ [ +mode+ ] dip <participant-changed> ] dip to-chat ] 3bi ; ! FIXME
+ [ [ participant-changed new
+ [ (>>nick) ] [ (>>parameter) ] [ +mode+ >>action ] tri ] dip to-chat ]
+ 3bi ; ! FIXME
DEFER: me?
M: nick process-message
[ irc-message-sender ] [ trailing>> ] bi rename-participant-in-all ;
-! M: mode process-message ( mode -- )
-! [ channel-mode? ] keep and [
-! [ name>> ] [ mode>> ] [ parameter>> ] tri
-! [ change-participant-mode ] [ 2drop ] if*
-! ] when* ;
+M: mode process-message ( mode -- )
+ [ channel-mode? ] keep and [
+ [ name>> ] [ mode>> ] [ parameter>> ] tri
+ [ change-participant-mode ] [ 2drop ] if*
+ ] when* ;
: >nick/mode ( string -- nick mode )
dup first "+@" member? [ unclip ] [ 0 ] if participant-mode ;
: attach-chat ( irc-chat irc-client -- ) [ (attach-chat) ] with-irc-client ;
- : dettach-chat ( irc-chat -- )
+ : detach-chat ( irc-chat -- )
[ client>> ] keep '[ _ (remove-chat) ] with-irc-client ;
: speak ( message irc-chat -- )