<p>LuaIRC is a low-level IRC library for Lua. All functions raise Lua exceptions on error. Use <code>new</code> to create a new IRC object.<br/> Example:<br/><br/><code> require "irc"<br/> local sleep = require "socket".sleep<br/><br/> local s = irc.new{nick = "example"}<br/><br/> s:hook("OnChat", function(user, channel, message)<br/> print(("[%s] %s: %s"):format(channel, user.nick, message))<br/> end)<br/><br/> s:connect("irc.example.net")<br/> s:join("#example")<br/><br/> while true do<br/> s:think()<br/> sleep(0.5)<br/> end<br/></code></p>
t: Table with fields <code>target, nick, add</code> and/or <code>rem</code>. <code>target</code> or <code>nick</code> specifies the user or channel to add/remove modes. <code>add</code> is a list of modes to add to the user or channel. <code>rem</code> is a list of modes to remove from the user or channel.
</li>
</ul>
<h3>Usage:</h3>
Example which sets +m (moderated) for #channel: <br/><code>irc:setMode{target = "#channel", add = "m"}</code>
Handle incoming data for <code>irc</code>, and invoke previously hooked callbacks based on new server input. You should call this in some kind of main loop, or at least often enough to not time out.
<dd>Table with connection information. <ul><li><code>host</code> - Server host name.</li><li><code>port</code> - Server port. [defaults to <code>6667</code>]</li><li><code>timeout</code> - Connect timeout. [defaults to <code>30</code>]</li><li><code>password</code> - Server password.</li><li><code>secure</code> - Boolean to enable TLS connection, pass a params table (described, [luasec]) to control</li></ul> [luasec]: http://www.inf.puc-rio.br/~brunoos/luasec/reference.html
<dd>List of hooks you can use with irc:hook. The parameter list describes the parameters passed to the callback function. <ul><li><code>OnRaw(line) - (any non false/nil return value assumes line handled and will not be further processed)</code></li><li><code>OnDisconnect(message, errorOccurred)</code></li><li><code>OnChat(user, channel, message)</code></li><li><code>OnNotice(user, channel, message)</code></li><li><code>OnJoin(user, channel)</code>*</li><li><code>OnPart(user, channel)</code>*</li><li><code>OnQuit(user, message)</code></li><li><code>NickChange(user, newnick, channel)</code>*<2A></li><li><code>NameList(channel, names)</code></li><li><code>OnTopic(channel, topic)</code></li><li><code>OnTopicInfo(channel, creator, timeCreated)</code></li><li><code>OnKick(channel, nick, kicker, reason)</code>* (kicker is a <code>user</code> table)</li><li><code>OnUserMode(modes)</code></li><li><code>OnChannelMode(user, channel, modes)</code></li><li><code>OnModeChange(user, target, modes)</code>*</li></ul> * Event also invoked for yourself. <20> Channel passed only when user tracking is enabled
<dd>Table with information about a user. <ul><li><code>nick</code> - User nickname. Always present.</li><li><code>username</code> - User username.</li><li><code>host</code> - User hostname.</li><li><code>realname</code> - User real name.</li><li><code>access</code> - User access, available in channel-oriented callbacks. Can be '+', '@', and others, depending on the server.</li></ul> Apart from <code>nick</code>, fields may be missing. To fill them in, enable user tracking and use irc:whois.