an experimental irc client
at 6de3d13bd97e746ea173c2d17a94149dcd885c77 60 lines 2.0 kB view raw
1comlink_connection(3) 2 3# NAME 4 5comlink_connection - a lua type representing a connection to an IRC server 6 7# SYNOPSIS 8 9*local conn = comlink.connect*(_config_) 10 11*conn.on_connect = function*(_conn_) 12 13*conn.on_message = function*(_channel_, _sender_, _msg_) 14 15*local name = conn.name*() 16 17*conn.join*(_channel_) 18 19 20 21# DESCRIPTION 22 23A *connection* represents the connection to the IRC server. A *connection* is 24received after calling *comlink.connect*, which posts an event to connect to the 25server. The entire lua file is executed prior to the connection occuring. This 26behavior allows setting of callbacks on the connection after calling connect. 27All callbacks are called from the main thread, and will block the event loop 28until they return. 29 30*conn.on_connect* 31 A callback which receives the *connection* object. This callback is 32 called when comlink receives a *RPL_WELCOME* command from the server. An 33 example usage is to join channels after a connection has been 34 established. The callback receives a *connection* object because in the 35 presence of _soju.im/bouncer-networks_, networks may be discovered that 36 the user never configured. These discovered networks will inherit the 37 callbacks from the bouncer connection. Users of this callback may want 38 to perform different actions based on the *connection*, which is best 39 verified using the *name* function. 40 41*conn.on_message* 42 A callback which is called after any *PRIVMSG* or *NOTICE* is received 43 on the *connection*. The callback receives the channel, the sender, and 44 the content of the message - all as strings. The channel may be a 45 nickname in the case of a direct message. 46 47*conn.join* 48 Accepts a string as the channel name to join. This performs the IRC 49 command *JOIN*. 50 51# RETURN VALUES 52 53*conn.name* 54 Returns a string which is the name of the connection. This is usually 55 the URL, but may be something else if it is a discovered network from a 56 bouncer. 57 58# SEE ALSO 59 60*comlink*(1), *comlink*(3)