]> gitweb.factorcode.org Git - factor.git/blob - extra/irc/client/chats/chats.factor
Switch to https urls
[factor.git] / extra / irc / client / chats / chats.factor
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 ;
5 IN: irc.client.chats
6
7 CONSTANT: irc-port 6667 ! Default irc port
8
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 ;
13 SYMBOL: +server-chat+
14
15 : <irc-server-chat> ( -- irc-server-chat )
16     irc-server-chat new
17          <mailbox> >>in-messages ;
18
19 : <irc-channel-chat> ( name -- irc-channel-chat )
20     irc-channel-chat new
21          swap       >>name
22          <mailbox>  >>in-messages
23          f          >>password
24          H{ } clone >>participants
25          t          >>clear-participants ;
26
27 : <irc-nick-chat> ( name -- irc-nick-chat )
28     irc-nick-chat new
29          swap      >>name
30          <mailbox> >>in-messages ;
31
32 TUPLE: irc-profile server port nickname password ;
33 C: <irc-profile> irc-profile
34
35 TUPLE: irc-client profile stream in-messages out-messages
36     chats is-running nick connect is-ready
37     reconnect-time reconnect-attempts
38     exceptions ;
39
40 : <irc-client> ( profile -- irc-client )
41     dup nickname>> irc-client new
42         swap       >>nick
43         swap       >>profile
44         <mailbox>  >>in-messages
45         <mailbox>  >>out-messages
46         H{ } clone >>chats
47         30 seconds >>reconnect-time
48         10         >>reconnect-attempts
49         V{ } clone >>exceptions
50         [ <inet> utf8 <client> drop ] >>connect ;
51
52 SINGLETONS: irc-chat-end irc-end irc-disconnected irc-connected ;