]> gitweb.factorcode.org Git - factor.git/blob - extra/irc/client/client-docs.factor
d95d2bc2c6c0d1d34feee136ad135850d702fc66
[factor.git] / extra / irc / client / client-docs.factor
1 USING: help.markup help.syntax quotations kernel irc.messages irc.messages.base irc.messages.parser ;
2 IN: irc.client
3
4 HELP: irc-client "IRC Client object" ;
5
6 HELP: irc-server-chat "Chat for server messages unmanaged by other chats" ;
7
8 HELP: irc-channel-chat "Chat for irc channels" ;
9
10 HELP: irc-nick-chat "Chat for irc users" ;
11
12 HELP: irc-profile "IRC Client profile object" ;
13
14 HELP: connect-irc "Connecting to an irc server"
15 { $values { "irc-client" "an irc client object" } }
16 { $description "Connects and logins " { $link irc-client } " using the settings specified on its " { $link irc-profile } "." } ;
17
18 HELP: attach-chat "Chatting with irc channels/users/etc"
19 { $values { "irc-chat" "an irc chat object" } { "irc-client" "an irc client object" } }
20 { $description "Registers " { $snippet "irc-chat" } " with " { $snippet "irc-client" } " and starts listening." } ;
21
22 HELP: detach-chat "Stop an unregister chat"
23 { $values { "irc-chat" "an irc chat object" } }
24 { $description "Unregisters " { $snippet "irc-chat" } " from " { $snippet "irc-client" } " and stops listening. This is how you part from a channel." } ;
25
26 HELP: terminate-irc "Terminates an irc client"
27 { $values { "irc-client" "an irc client object" } }
28 { $description "Terminates all activity by " { $link irc-client } " cleaning up resources and notifying chats." } ;
29
30 HELP: speak "Sends a message through a chat"
31 { $values { "message" "a string or irc message object" } { "irc-chat" "an irc chat object" } }
32 { $description "Sends " { $snippet "message" } " through " { $snippet "irc-chat" } ". Strings are automatically promoted to privmsg objects." } ;
33
34 HELP: hear "Reads a message from a chat"
35 { $values { "irc-chat" "an irc chat object" } { "message" "an irc message object" } }
36 { $description "Reads " { $snippet "message" } " from " { $snippet "irc-chat" } "." } ;
37
38 ARTICLE: "irc.client" "IRC Client"
39 "An IRC Client library"
40 { $heading "IRC objects:" }
41 { $subsection irc-client }
42 { $heading "Chat objects:" }
43 { $subsection irc-server-chat }
44 { $subsection irc-channel-chat }
45 { $subsection irc-nick-chat }
46 { $heading "Setup objects:" }
47 { $subsection irc-profile }
48 { $heading "Words:" }
49 { $subsection connect-irc }
50 { $subsection terminate-irc }
51 { $subsection attach-chat }
52 { $subsection detach-chat }
53 { $subsection hear }
54 { $subsection speak }
55 { $heading "IRC messages" }
56 "Some of the RFC defined irc messages as objects:"
57 { $table
58   { { $link irc-message } "base of all irc messages" }
59   { { $link rpl-welcome } "logged in to server" }
60   { { $link ping } "ping message" }
61   { { $link join } "channel join" }
62   { { $link part } "channel part" }
63   { { $link quit } "quit from irc" }
64   { { $link privmsg } "private message (to client or channel)" }
65   { { $link kick } "kick from channel" }
66   { { $link rpl-names } "list of participants in channel" }
67   { { $link rpl-nickname-in-use } "chosen nick is in use by another client" }
68   { { $link notice } "notice message" }
69   { { $link mode } "mode change" }
70   { { $link unhandled } "uninmplemented/unhandled message" }
71   }
72 { $heading "Special messages" }
73 "Some special messages that are created by the library and not by the irc server."
74 { $table
75   { { $link irc-chat-end } "sent to a chat when it has been detached from the client, the chat should stop after it receives this message. " }
76   { { $link irc-end } " sent when the client isn't running anymore, chats should stop after it receives this message." }
77   { { $link irc-disconnected } " sent to notify chats that connection was lost." }
78   { { $link irc-connected } " sent to notify chats that a connection with the irc server was established." } }
79
80 { $heading "Example:" }
81 { $code
82   "USING: irc.client ;"
83   "SYMBOL: bot"
84   "SYMBOL: mychannel"
85   "! Create the profile and client objects"
86   "\"irc.freenode.org\" irc-port \"mybot123\" f <irc-profile> <irc-client> bot set"
87   "! Connect to the server"
88   "bot get connect-irc"
89   "! Create a channel chat"
90   "\"#mychannel123\" <irc-channel-chat> mychannel set"
91   "! Register and start chat (this joins the channel)"
92   "mychannel get bot get attach-chat"
93   "! Send a message to the channel"
94   "\"what's up?\" mychannel get speak"
95   "! Read a message from the channel"
96   "mychannel get hear"
97 }
98   ;
99
100 ABOUT: "irc.client"