2010-06-14 15:57:08 +02:00
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
< html >
< head >
< title > Reference< / title >
< link rel = "stylesheet" href = "../luadoc.css" type = "text/css" / >
<!-- meta http - equiv="Content - Type" content="text/html; charset=UTF - 8"/ -->
< / head >
< body >
< div id = "container" >
< div id = "product" >
< div id = "product_logo" > < / div >
< div id = "product_name" > < big > < b > < / b > < / big > < / div >
< div id = "product_description" > < / div >
< / div > <!-- id="product" -->
< div id = "main" >
< div id = "navigation" >
< h1 > LuaDoc< / h1 >
< ul >
< li > < a href = "../index.html" > Index< / a > < / li >
< / ul >
<!-- Module list -->
< h1 > Modules< / h1 >
< ul >
< li > < strong > irc< / strong > < / li >
< / ul >
<!-- File list -->
< / div > <!-- id="navigation" -->
< div id = "content" >
< h1 > Module < code > irc< / code > < / h1 >
2010-06-14 16:12:33 +02:00
< 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 >
2010-06-14 15:57:08 +02:00
< h2 > Functions< / h2 >
< table class = "function_list" >
< tr >
< td class = "name" nowrap > < a href = "#irc:connect" > irc:connect< / a > (server, port, timeout)< / td >
2010-06-15 09:48:19 +02:00
< td class = "summary" > Connect < code > irc< / code > to an IRC server.< / td >
2010-06-14 15:57:08 +02:00
< / tr >
< tr >
< td class = "name" nowrap > < a href = "#irc:disconnect" > irc:disconnect< / a > (message)< / td >
2010-06-15 09:48:19 +02:00
< td class = "summary" > Disconnect < code > irc< / code > from the server.< / td >
2010-06-14 15:57:08 +02:00
< / tr >
< tr >
< td class = "name" nowrap > < a href = "#irc:hook" > irc:hook< / a > (name, id, f)< / td >
2010-06-15 09:48:19 +02:00
< td class = "summary" > Hook a function to an event.< / td >
2010-06-14 15:57:08 +02:00
< / tr >
< tr >
< td class = "name" nowrap > < a href = "#irc:join" > irc:join< / a > (channel, key)< / td >
2010-06-15 09:48:19 +02:00
< td class = "summary" > Join a channel.< / td >
2010-06-14 15:57:08 +02:00
< / tr >
< tr >
< td class = "name" nowrap > < a href = "#irc:part" > irc:part< / a > (channel)< / td >
2010-06-15 09:48:19 +02:00
< td class = "summary" > Leave a channel.< / td >
2010-06-14 15:57:08 +02:00
< / tr >
< tr >
< td class = "name" nowrap > < a href = "#irc:send" > irc:send< / a > (fmt, ...)< / td >
2010-06-15 09:48:19 +02:00
< td class = "summary" > Send a raw line of IRC to the server.< / td >
2010-06-14 15:57:08 +02:00
< / tr >
< tr >
2010-06-15 09:48:19 +02:00
< td class = "name" nowrap > < a href = "#irc:sendChat" > irc:sendChat< / a > (target, message)< / td >
< td class = "summary" > Send a message to a channel or user.< / td >
2010-06-14 15:57:08 +02:00
< / tr >
< tr >
2010-06-15 09:48:19 +02:00
< td class = "name" nowrap > < a href = "#irc:sendNotice" > irc:sendNotice< / a > (target, message)< / td >
< td class = "summary" > Send a notice to a channel or user.< / td >
2010-06-14 15:57:08 +02:00
< / tr >
< tr >
< td class = "name" nowrap > < a href = "#irc:setMode" > irc:setMode< / a > (t)< / td >
2010-06-15 09:48:19 +02:00
< td class = "summary" > Add/remove modes for a channel or nick.< / td >
2010-06-14 15:57:08 +02:00
< / tr >
< tr >
< td class = "name" nowrap > < a href = "#irc:think" > irc:think< / a > ()< / td >
2010-06-15 09:48:19 +02:00
< td class = "summary" > Handle incoming data for < code > irc< / code > , and invoke previously hooked callbacks based on new server input.< / td >
2010-06-14 15:57:08 +02:00
< / tr >
< tr >
< td class = "name" nowrap > < a href = "#irc:trackUsers" > irc:trackUsers< / a > (b)< / td >
2010-06-15 09:48:19 +02:00
< td class = "summary" > Turn user information tracking on or off.< / td >
2010-06-14 15:57:08 +02:00
< / tr >
< tr >
< td class = "name" nowrap > < a href = "#irc:unhook" > irc:unhook< / a > (name, id)< / td >
2010-06-15 09:48:19 +02:00
< td class = "summary" > Remove previous hooked callback.< / td >
2010-06-14 15:57:08 +02:00
< / tr >
< tr >
< td class = "name" nowrap > < a href = "#irc:whois" > irc:whois< / a > (nick)< / td >
2010-06-15 09:48:19 +02:00
< td class = "summary" > Look up user info.< / td >
2010-06-14 15:57:08 +02:00
< / tr >
< tr >
< td class = "name" nowrap > < a href = "#new" > new< / a > (user)< / td >
< td class = "summary" > Create a new IRC object.< / td >
< / tr >
< / table >
2010-06-15 09:48:19 +02:00
< h2 > Tables< / h2 >
< table class = "table_list" >
< tr >
< td class = "name" nowrap > < a href = "#Hooks" > Hooks< / a > < / td >
< td class = "summary" > List of hooks you can use with irc:hook.< / td >
< / tr >
< tr >
< td class = "name" nowrap > < a href = "#User" > User< / a > < / td >
< td class = "summary" > Table with information about a user.< / td >
< / tr >
< / table >
2010-06-14 15:57:08 +02:00
< br / >
< br / >
< h2 > < a name = "functions" > < / a > Functions< / h2 >
< dl class = "function" >
< dt > < a name = "irc:connect" > < / a > < strong > irc:connect< / strong > (server, port, timeout)< / dt >
< dd >
2010-06-15 09:48:19 +02:00
Connect < code > irc< / code > to an IRC server.
2010-06-14 15:57:08 +02:00
< h3 > Parameters< / h3 >
< ul >
< li >
2010-06-15 09:48:19 +02:00
server: Server address.
2010-06-14 15:57:08 +02:00
< / li >
< li >
2010-06-15 09:48:19 +02:00
port: Server port. [default 6667]
2010-06-14 15:57:08 +02:00
< / li >
< li >
2010-06-15 09:48:19 +02:00
timeout: Connection timeout value in seconds. [default 30]
2010-06-14 15:57:08 +02:00
< / li >
< / ul >
< / dd >
< dt > < a name = "irc:disconnect" > < / a > < strong > irc:disconnect< / strong > (message)< / dt >
< dd >
2010-06-15 09:48:19 +02:00
Disconnect < code > irc< / code > from the server.
2010-06-14 15:57:08 +02:00
< h3 > Parameters< / h3 >
< ul >
< li >
2010-06-15 09:48:19 +02:00
message: Quit message.
2010-06-14 15:57:08 +02:00
< / li >
< / ul >
< / dd >
< dt > < a name = "irc:hook" > < / a > < strong > irc:hook< / strong > (name, id, f)< / dt >
< dd >
2010-06-15 09:48:19 +02:00
Hook a function to an event.
2010-06-14 15:57:08 +02:00
< h3 > Parameters< / h3 >
< ul >
< li >
2010-06-15 09:48:19 +02:00
name: Name of event.
2010-06-14 15:57:08 +02:00
< / li >
< li >
2010-06-15 09:48:19 +02:00
id: Unique tag.
2010-06-14 15:57:08 +02:00
< / li >
< li >
2010-06-15 09:48:19 +02:00
f: Callback function. [defaults to < code > id< / code > ]
2010-06-14 15:57:08 +02:00
< / li >
< / ul >
2010-06-15 09:48:19 +02:00
< h3 > See also:< / h3 >
< ul >
< li > < a href = "../modules/irc.html#Hooks" >
Hooks
< / a >
< / ul >
2010-06-14 15:57:08 +02:00
< / dd >
< dt > < a name = "irc:join" > < / a > < strong > irc:join< / strong > (channel, key)< / dt >
< dd >
2010-06-15 09:48:19 +02:00
Join a channel.
2010-06-14 15:57:08 +02:00
< h3 > Parameters< / h3 >
< ul >
< li >
2010-06-15 09:48:19 +02:00
channel: Channel to join.
2010-06-14 15:57:08 +02:00
< / li >
< li >
2010-06-15 09:48:19 +02:00
key: Channel password. [optional]
2010-06-14 15:57:08 +02:00
< / li >
< / ul >
< / dd >
< dt > < a name = "irc:part" > < / a > < strong > irc:part< / strong > (channel)< / dt >
< dd >
2010-06-15 09:48:19 +02:00
Leave a channel.
2010-06-14 15:57:08 +02:00
< h3 > Parameters< / h3 >
< ul >
< li >
2010-06-15 09:48:19 +02:00
channel: Channel to leave.
2010-06-14 15:57:08 +02:00
< / li >
< / ul >
< / dd >
< dt > < a name = "irc:send" > < / a > < strong > irc:send< / strong > (fmt, ...)< / dt >
< dd >
2010-06-15 09:48:19 +02:00
Send a raw line of IRC to the server.
2010-06-14 15:57:08 +02:00
< h3 > Parameters< / h3 >
< ul >
< li >
2010-06-15 09:48:19 +02:00
fmt: Line to be sent, excluding newline characters.
2010-06-14 15:57:08 +02:00
< / li >
< li >
2010-06-15 09:48:19 +02:00
...: Format parameters for < code > fmt< / code > , with < code > string.format< / code > semantics.
2010-06-14 15:57:08 +02:00
< / li >
< / ul >
< / dd >
2010-06-15 09:48:19 +02:00
< dt > < a name = "irc:sendChat" > < / a > < strong > irc:sendChat< / strong > (target, message)< / dt >
2010-06-14 15:57:08 +02:00
< dd >
2010-06-15 09:48:19 +02:00
Send a message to a channel or user.
2010-06-14 15:57:08 +02:00
< h3 > Parameters< / h3 >
< ul >
< li >
2010-06-15 09:48:19 +02:00
target: Nick or channel to send to.
2010-06-14 15:57:08 +02:00
< / li >
< li >
2010-06-15 09:48:19 +02:00
message: Message to send.
2010-06-14 15:57:08 +02:00
< / li >
< / ul >
< / dd >
2010-06-15 09:48:19 +02:00
< dt > < a name = "irc:sendNotice" > < / a > < strong > irc:sendNotice< / strong > (target, message)< / dt >
2010-06-14 15:57:08 +02:00
< dd >
2010-06-15 09:48:19 +02:00
Send a notice to a channel or user.
2010-06-14 15:57:08 +02:00
< h3 > Parameters< / h3 >
< ul >
< li >
2010-06-15 09:48:19 +02:00
target: Nick or channel to send to.
2010-06-14 15:57:08 +02:00
< / li >
< li >
2010-06-15 09:48:19 +02:00
message: Notice to send.
2010-06-14 15:57:08 +02:00
< / li >
< / ul >
< / dd >
< dt > < a name = "irc:setMode" > < / a > < strong > irc:setMode< / strong > (t)< / dt >
< dd >
2010-06-15 09:48:19 +02:00
Add/remove modes for a channel or nick.
2010-06-14 15:57:08 +02:00
< h3 > Parameters< / h3 >
< ul >
< li >
2010-06-15 09:48:19 +02:00
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.
2010-06-14 15:57:08 +02:00
< / li >
< / ul >
2010-06-15 09:48:19 +02:00
< h3 > Usage:< / h3 >
Example which sets +m (moderated) for #channel: < br / > < code > irc:setMode{target = "#channel", add = "m"}< / code >
2010-06-14 15:57:08 +02:00
< / dd >
< dt > < a name = "irc:think" > < / a > < strong > irc:think< / strong > ()< / dt >
< dd >
2010-06-15 09:48:19 +02:00
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.
2010-06-14 15:57:08 +02:00
< / dd >
< dt > < a name = "irc:trackUsers" > < / a > < strong > irc:trackUsers< / strong > (b)< / dt >
< dd >
2010-06-15 09:48:19 +02:00
Turn user information tracking on or off. User tracking is enabled by default.
2010-06-14 15:57:08 +02:00
< h3 > Parameters< / h3 >
< ul >
< li >
2010-06-15 09:48:19 +02:00
b: Boolean whether or not to track user information.
2010-06-14 15:57:08 +02:00
< / li >
< / ul >
< / dd >
< dt > < a name = "irc:unhook" > < / a > < strong > irc:unhook< / strong > (name, id)< / dt >
< dd >
2010-06-15 09:48:19 +02:00
Remove previous hooked callback.
2010-06-14 15:57:08 +02:00
< h3 > Parameters< / h3 >
< ul >
< li >
2010-06-15 09:48:19 +02:00
name: Name of event.
2010-06-14 15:57:08 +02:00
< / li >
< li >
2010-06-15 09:48:19 +02:00
id: Unique tag.
2010-06-14 15:57:08 +02:00
< / li >
< / ul >
< / dd >
< dt > < a name = "irc:whois" > < / a > < strong > irc:whois< / strong > (nick)< / dt >
< dd >
2010-06-15 09:48:19 +02:00
Look up user info.
2010-06-14 15:57:08 +02:00
< h3 > Parameters< / h3 >
< ul >
< li >
2010-06-15 09:48:19 +02:00
nick: Nick of user to query.
2010-06-14 15:57:08 +02:00
< / li >
< / ul >
2010-06-15 09:48:19 +02:00
< h3 > Return value:< / h3 >
Table with fields < code > userinfo< / code > , < code > node< / code > , < code > channels< / code > and < code > account< / code > .
2010-06-14 15:57:08 +02:00
< / dd >
< dt > < a name = "new" > < / a > < strong > new< / strong > (user)< / dt >
< dd >
2010-06-15 09:48:19 +02:00
Create a new IRC object. Use < code > irc:connect< / code > to connect to a server.
2010-06-14 15:57:08 +02:00
< h3 > Parameters< / h3 >
< ul >
< li >
2010-06-15 09:48:19 +02:00
user: Table with fields < code > nick< / code > , < code > username< / code > and < code > realname< / code > . The < code > nick< / code > field is required.
2010-06-14 15:57:08 +02:00
< / li >
< / ul >
2010-06-15 09:48:19 +02:00
< h3 > Return value:< / h3 >
Returns a new < code > irc< / code > object.
2010-06-14 15:57:08 +02:00
< / dd >
< / dl >
2010-06-15 09:48:19 +02:00
< h2 > < a name = "tables" > < / a > Tables< / h2 >
< dl class = "table" >
< dt > < a name = "Hooks" > < / a > < strong > Hooks< / strong > < / dt >
< dd > List of hooks you can use with irc:hook. The parameter list describes the parameters passed to the callback function. < ul > < 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)< / code > *< / li > < li > < code > NameList(channel, names)< / code > < / li > < / ul > * Event also invoked for yourself.
< / dd >
< dt > < a name = "User" > < / a > < strong > User< / strong > < / dt >
< 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.
< / dd >
< / dl >
2010-06-14 15:57:08 +02:00
< / div > <!-- id="content" -->
< / div > <!-- id="main" -->
< div id = "about" >
< p > < a href = "http://validator.w3.org/check?uri=referer" > < img src = "http://www.w3.org/Icons/valid-xhtml10" alt = "Valid XHTML 1.0!" height = "31" width = "88" / > < / a > < / p >
< / div > <!-- id="about" -->
< / div > <!-- id="container" -->
< / body >
< / html >