1 ! Copyright (C) 2009 Bruno Deferrari
2 ! See https://factorcode.org/license.txt for BSD license.
3 USING: accessors calendar concurrency.mailboxes
4 io.encodings.utf8 io.sockets kernel ;
7 CONSTANT: irc-port 6667 ! Default irc port
9 TUPLE: irc-chat in-messages client ;
10 TUPLE: irc-server-chat < irc-chat ;
11 TUPLE: irc-channel-chat < irc-chat name password participants clear-participants ;
12 TUPLE: irc-nick-chat < irc-chat name ;
15 : <irc-server-chat> ( -- irc-server-chat )
17 <mailbox> >>in-messages ;
19 : <irc-channel-chat> ( name -- irc-channel-chat )
22 <mailbox> >>in-messages
24 H{ } clone >>participants
25 t >>clear-participants ;
27 : <irc-nick-chat> ( name -- irc-nick-chat )
30 <mailbox> >>in-messages ;
32 TUPLE: irc-profile server port nickname password ;
33 C: <irc-profile> irc-profile
35 TUPLE: irc-client profile stream in-messages out-messages
36 chats is-running nick connect is-ready
37 reconnect-time reconnect-attempts
40 : <irc-client> ( profile -- irc-client )
41 dup nickname>> irc-client new
44 <mailbox> >>in-messages
45 <mailbox> >>out-messages
47 30 seconds >>reconnect-time
48 10 >>reconnect-attempts
49 V{ } clone >>exceptions
50 [ <inet> utf8 <client> drop ] >>connect ;
52 SINGLETONS: irc-chat-end irc-end irc-disconnected irc-connected ;