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