1picoirc(n) Simple embeddable IRC interface picoirc(n)
2
3
4
5______________________________________________________________________________
6
8 picoirc - Small and simple embeddable IRC client.
9
11 package require Tcl
12
13 package require picoirc ?0.5?
14
15 ::picoirc::connect callback nick url
16
17 ::picoirc::post context channel message
18
19 ::picoirc::splituri uri
20
21 ::picoirc::send context line
22
23_________________________________________________________________
24
26 This package provides a general purpose minimal IRC client suitable for
27 embedding in other applications. All communication with the parent
28 application is done via an application provided callback procedure.
29 Each connection has its own state so you can hook up multiple servers
30 in a single application instance.
31
32 To initiate an IRC connection you must call picoirc::connect with a
33 callback procedure, a nick-name to use on IRC and the IRC URL that
34 describes the connection. This will return a variable name that is the
35 irc connection context. See CALLBACK for details.
36
37 This package is a fairly simple IRC client. If you need something with
38 more capability investigate the irc package.
39
41 ::picoirc::connect callback nick url
42 Create a new irc connection to the server specified by url and
43 login using the nick as the username. The callback must be as
44 specified in CALLBACK. Returns a package-specific variable that
45 is used when calling other commands in this package.
46
47 ::picoirc::post context channel message
48 This should be called to process user input and send it to the
49 server. A number of commands are recognised when prefixed with a
50 forward-slash (/). Such commands are converted to IRC command
51 sequences and then sent.
52
53 ::picoirc::splituri uri
54 Splits an IRC scheme uniform resource indicator into its compo‐
55 nent parts. Returns a list of server, port and channel. The
56 default port is 6667 and there is no default channel.
57
58 ::picoirc::send context line
59 This command is where all raw output to the server is handled.
60 The default action is to write the line to the irc socket. How‐
61 ever, before this happens the callback is called with "debug
62 write". This permits the application author to inspect the raw
63 IRC data and if desired to return a break error code to halt
64 further processing. In this way the application can override the
65 default send via the callback procedure.
66
68 The callback must look like:
69
70 proc Callback {context state args} {
71 }
72
73 where context is the irc context variable name (in case you need to
74 pass it back to a picoirc procedure). state is one of a number of
75 states as described below.
76
77 init called just before the socket is created
78
79 connect
80 called once we have connected, before we join any channels
81
82 close called when the socket gets closed, before the context is
83 deleted. If an error occurs before we get connected the only
84 argument will be the socket error message.
85
86 userlist channel nicklist
87 called to notify the application of an updated userlist. This is
88 generated when the output of the NAMES irc command is seen. The
89 package collects the entire output which can span a number of
90 output lines from the server and calls this callback when they
91 have all been received.
92
93 chat target nick message type
94 called when a message arrives. target is the identity that the
95 message was targetted for. This can be the logged in nick or a
96 channel name. nick is the name of the sender of the message.
97 message is the message text. type is set to "ACTION" if the mes‐
98 sage was sent as a CTCP ACTION
99
100 system channel message
101 called when a system message is received
102
103 topic channel topic
104 called when the channel topic string is seen. topic is the text
105 of the channel topic.
106
107 traffic action channel nick ?newnick?
108 called when users join, leave or change names. action is either
109 entered, left or nickchange and nick is the user doing the
110 action. newnick is the new name if action is nickchange.
111
112 NOTE: channel is often empty for these messages as nick activi‐
113 ties are global for the irc server. You will have to manage the
114 nick for all connected channels yourself.
115
116 version
117 This is called to request a version string to use to override
118 the internal version. If implemented, you should return as colon
119 delimited string as
120
121 Appname:Appversion:LibraryVersion
122
123 For example, the default is
124
125 PicoIRC:[package provide picoirc]:Tcl [info patchlevel]
126
127 debug type raw
128 called when data is either being read or written to the network
129 socket. type is set to read when reading data and write if the
130 data is to be written. raw is the unprocessed IRC protocol data.
131
132 In both cases the application can return a break error code to
133 interrupt further processing of the raw data. If this is a read
134 operation then the package will not handle this line. If the
135 operation is write then the package will not send the data. This
136 callback is intended for debugging protocol issues but could be
137 used to redirect all input and output if desired.
138
140 rfc 1459
141
143 chat, irc
144
145
146
147irc 0.5 picoirc(n)