diff --git a/doc/files/irc.html b/doc/files/irc.html new file mode 100644 index 0000000..ff04daa --- /dev/null +++ b/doc/files/irc.html @@ -0,0 +1,215 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

File irc.luadoc

+ + +

LuaIRC is a low-level IRC library for Lua.

+ + + + + + +

Functions

+ + + + + + + + + + + + + + + + + +
meta:hook (name, id [, f])Hooks function f to event name, with the unique tag id.
meta:send (fmt, ...)Sends a line of raw IRC to the server Test Test 2
new (user)Create a new IRC object.
+ + + + + + +
+
+ + + + +

Functions

+
+ + + +
meta:hook (name, id [, f])
+
+Hooks function f to event name, with the unique tag id. If parameter f is absent, id is assumed to be both the callback function and unique tag. + + +

Parameters

+
    + +
  • + name: +
  • + +
  • + id [: +
  • + +
  • + f]: +
  • + +
+ + + + + + + + +
+ + + + +
meta:send (fmt, ...)
+
+Sends a line of raw IRC to the server Test Test 2 + + +

Parameters

+
    + +
  • + fmt: +
  • + +
  • + ...: +
  • + +
+ + + + + + + + +
+ + + + +
new (user)
+
+Create a new IRC object. The user parameter can contain fields nick, username and realname. The nick field is required. + + +

Parameters

+
    + +
  • + user: +
  • + +
+ + + + + + + + +
+ + +
+ + + + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/doc/index.html b/doc/index.html new file mode 100644 index 0000000..639cb70 --- /dev/null +++ b/doc/index.html @@ -0,0 +1,84 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ + + +

Modules

+ + + + + + + + +
ircLuaIRC is a low-level IRC library for Lua.
+ + + + + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ + diff --git a/doc/irc.luadoc b/doc/irc.luadoc new file mode 100644 index 0000000..2680634 --- /dev/null +++ b/doc/irc.luadoc @@ -0,0 +1,131 @@ +--- LuaIRC is a low-level IRC library for Lua. +-- All functions raise Lua exceptions on error. +-- +-- Use new to create a new IRC object.
+-- Example:

+-- +--require "irc"
+--local sleep = require "socket".sleep
+--
+--local s = irc.new{nick = "example"}
+--
+--s:hook("OnChat", function(user, channel, message)
+-- print(("[%s] %s: %s"):format(channel, user.nick, message))
+--end)
+--
+--s:connect("irc.example.net")
+--s:join("#example")
+--
+--while true do
+-- s:think()
+-- sleep(0.5)
+--end
+--
+ +module "irc" + +--- Create a new IRC object. Use irc:connect to connect to a server. +-- @param user Table with fields nick, username and realname. +-- The nick field is required. +-- +-- @return Returns a new irc object. +function new(user) + +--- Hook a function to an event. +-- @param name Name of event. +-- @param id Unique tag. +-- @param f Callback function. [defaults to id] +-- @see Hooks +function irc:hook(name, id, f) + +--- Remove previous hooked callback. +-- @param name Name of event. +-- @param id Unique tag. +function irc:unhook(name, id) + +--- Connect irc to an IRC server. +-- @param server Server address. +-- @param port Server port. [default 6667] +-- @param timeout Connection timeout value in seconds. [default 30] +function irc:connect(server, port, timeout) + +--- Disconnect irc from the server. +-- @param message Quit message. +function irc:disconnect(message) + +--- Handle incoming data for irc, 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. +function irc:think() + +--- Look up user info. +-- @param nick Nick of user to query. +-- @return Table with fields userinfo, node, channels and account. +function irc:whois(nick) + +--- Send a raw line of IRC to the server. +-- @param fmt Line to be sent, excluding newline characters. +-- @param ... Format parameters for fmt, with string.format semantics. +function irc:send(fmt, ...) + +--- Send a message to a channel or user. +-- @param target Nick or channel to send to. +-- @param message Message to send. +function irc:sendChat(target, message) + +--- Send a notice to a channel or user. +-- @param target Nick or channel to send to. +-- @param message Notice to send. +function irc:sendNotice(target, message) + +--- Join a channel. +-- @param channel Channel to join. +-- @param key Channel password. [optional] +function irc:join(channel, key) + +--- Leave a channel. +-- @param channel Channel to leave. +function irc:part(channel) + +--- Turn user information tracking on or off. User tracking is enabled by default. +-- @param b Boolean whether or not to track user information. +function irc:trackUsers(b) + +--- Add/remove modes for a channel or nick. +-- @param t Table with fields target, nick, add and/or rem. target or nick +-- specifies the user or channel to add/remove modes. add is a list of modes to add to the user or channel. +-- rem is a list of modes to remove from the user or channel. +-- @usage Example which sets +m (moderated) for #channel:
+-- irc:setMode{target = "#channel", add = "m"} +function irc:setMode(t) + +--internal +function irc:invoke(name, ...) +function irc:handle(prefix, cmd, params) +function irc:shutdown() + +--- List of hooks you can use with irc:hook. The parameter list describes the parameters passed to the callback function. +-- +-- * Event also invoked for yourself. +-- @name Hooks +-- @class table + +--- Table with information about a user. +-- +-- Apart from nick, fields may be missing. To fill them in, enable user tracking and use irc:whois. +-- @name User +-- @class table diff --git a/doc/luadoc.css b/doc/luadoc.css new file mode 100644 index 0000000..afc0063 --- /dev/null +++ b/doc/luadoc.css @@ -0,0 +1,286 @@ +body { + margin-left: 1em; + margin-right: 1em; + font-family: arial, helvetica, geneva, sans-serif; + background-color:#ffffff; margin:0px; +} + +code { + font-family: "Andale Mono", monospace; +} + +tt { + font-family: "Andale Mono", monospace; +} + +body, td, th { font-size: 11pt; } + +h1, h2, h3, h4 { margin-left: 0em; } + +textarea, pre, tt { font-size:10pt; } +body, td, th { color:#000000; } +small { font-size:0.85em; } +h1 { font-size:1.5em; } +h2 { font-size:1.25em; } +h3 { font-size:1.15em; } +h4 { font-size:1.06em; } + +a:link { font-weight:bold; color: #004080; text-decoration: none; } +a:visited { font-weight:bold; color: #006699; text-decoration: none; } +a:link:hover { text-decoration:underline; } +hr { color:#cccccc } +img { border-width: 0px; } + + +h3 { padding-top: 1em; } + +p { margin-left: 1em; } + +p.name { + font-family: "Andale Mono", monospace; + padding-top: 1em; + margin-left: 0em; +} + +blockquote { margin-left: 3em; } + +pre.example { + background-color: rgb(245, 245, 245); + border-top-width: 1px; + border-right-width: 1px; + border-bottom-width: 1px; + border-left-width: 1px; + border-top-style: solid; + border-right-style: solid; + border-bottom-style: solid; + border-left-style: solid; + border-top-color: silver; + border-right-color: silver; + border-bottom-color: silver; + border-left-color: silver; + padding: 1em; + margin-left: 1em; + margin-right: 1em; + font-family: "Andale Mono", monospace; + font-size: smaller; +} + + +hr { + margin-left: 0em; + background: #00007f; + border: 0px; + height: 1px; +} + +ul { list-style-type: disc; } + +table.index { border: 1px #00007f; } +table.index td { text-align: left; vertical-align: top; } +table.index ul { padding-top: 0em; margin-top: 0em; } + +table { + border: 1px solid black; + border-collapse: collapse; + margin-left: auto; + margin-right: auto; +} +th { + border: 1px solid black; + padding: 0.5em; +} +td { + border: 1px solid black; + padding: 0.5em; +} +div.header, div.footer { margin-left: 0em; } + +#container +{ + margin-left: 1em; + margin-right: 1em; + background-color: #f0f0f0; +} + +#product +{ + text-align: center; + border-bottom: 1px solid #cccccc; + background-color: #ffffff; +} + +#product big { + font-size: 2em; +} + +#product_logo +{ +} + +#product_name +{ +} + +#product_description +{ +} + +#main +{ + background-color: #f0f0f0; + border-left: 2px solid #cccccc; +} + +#navigation +{ + float: left; + width: 18em; + margin: 0; + vertical-align: top; + background-color: #f0f0f0; + overflow:visible; +} + +#navigation h1 { + background-color:#e7e7e7; + font-size:1.1em; + color:#000000; + text-align:left; + margin:0px; + padding:0.2em; + border-top:1px solid #dddddd; + border-bottom:1px solid #dddddd; +} + +#navigation ul +{ + font-size:1em; + list-style-type: none; + padding: 0; + margin: 1px; +} + +#navigation li +{ + text-indent: -1em; + margin: 0em 0em 0em 0.5em; + display: block; + padding: 3px 0px 0px 12px; +} + +#navigation li li a +{ + padding: 0px 3px 0px -1em; +} + +#content +{ + margin-left: 18em; + padding: 1em; + border-left: 2px solid #cccccc; + border-right: 2px solid #cccccc; + background-color: #ffffff; +} + +#about +{ + clear: both; + margin: 0; + padding: 5px; + border-top: 2px solid #cccccc; + background-color: #ffffff; +} + +@media print { + body { + font: 12pt "Times New Roman", "TimeNR", Times, serif; + } + a { font-weight:bold; color: #004080; text-decoration: underline; } + + #main { background-color: #ffffff; border-left: 0px; } + #container { margin-left: 2%; margin-right: 2%; background-color: #ffffff; } + + #content { margin-left: 0px; padding: 1em; border-left: 0px; border-right: 0px; background-color: #ffffff; } + + #navigation { display: none; + } + pre.example { + font-family: "Andale Mono", monospace; + font-size: 10pt; + page-break-inside: avoid; + } +} + +table.module_list td +{ + border-width: 1px; + padding: 3px; + border-style: solid; + border-color: #cccccc; +} +table.module_list td.name { background-color: #f0f0f0; } +table.module_list td.summary { width: 100%; } + +table.file_list +{ + border-width: 1px; + border-style: solid; + border-color: #cccccc; + border-collapse: collapse; +} +table.file_list td +{ + border-width: 1px; + padding: 3px; + border-style: solid; + border-color: #cccccc; +} +table.file_list td.name { background-color: #f0f0f0; } +table.file_list td.summary { width: 100%; } + + +table.function_list +{ + border-width: 1px; + border-style: solid; + border-color: #cccccc; + border-collapse: collapse; +} +table.function_list td +{ + border-width: 1px; + padding: 3px; + border-style: solid; + border-color: #cccccc; +} +table.function_list td.name { background-color: #f0f0f0; } +table.function_list td.summary { width: 100%; } + + +table.table_list +{ + border-width: 1px; + border-style: solid; + border-color: #cccccc; + border-collapse: collapse; +} +table.table_list td +{ + border-width: 1px; + padding: 3px; + border-style: solid; + border-color: #cccccc; +} +table.table_list td.name { background-color: #f0f0f0; } +table.table_list td.summary { width: 100%; } + +dl.function dt {border-top: 1px solid #ccc; padding-top: 1em;} +dl.function dd {padding-bottom: 1em;} +dl.function h3 {padding: 0; margin: 0; font-size: medium;} + +dl.table dt {border-top: 1px solid #ccc; padding-top: 1em;} +dl.table dd {padding-bottom: 1em;} +dl.table h3 {padding: 0; margin: 0; font-size: medium;} + +#TODO: make module_list, file_list, function_list, table_list inherit from a list + diff --git a/doc/modules/irc.html b/doc/modules/irc.html new file mode 100644 index 0000000..90a8104 --- /dev/null +++ b/doc/modules/irc.html @@ -0,0 +1,612 @@ + + + + Reference + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+ +

Module irc

+ +

LuaIRC is a low-level IRC library for Lua. All functions raise Lua exceptions on error. Use new to create a new IRC object.
Example:

require "irc"
local sleep = require "socket".sleep

local s = irc.new{nick = "example"}

s:hook("OnChat", function(user, channel, message)
print(("[%s] %s: %s"):format(channel, user.nick, message))
end)

s:connect("irc.example.net")
s:join("#example")

while true do
s:think()
sleep(0.5)
end

+ + + + + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
irc:connect (server, port, timeout)Connect irc to an IRC server.
irc:disconnect (message)Disconnect irc from the server.
irc:hook (name, id, f)Hook a function to an event.
irc:join (channel, key)Join a channel.
irc:part (channel)Leave a channel.
irc:send (fmt, ...)Send a raw line of IRC to the server.
irc:sendChat (target, message)Send a message to a channel or user.
irc:sendNotice (target, message)Send a notice to a channel or user.
irc:setMode (t)Add/remove modes for a channel or nick.
irc:think ()Handle incoming data for irc, and invoke previously hooked callbacks based on new server input.
irc:trackUsers (b)Turn user information tracking on or off.
irc:unhook (name, id)Remove previous hooked callback.
irc:whois (nick)Look up user info.
new (user)Create a new IRC object.
+ + + + +

Tables

+ + + + + + + + + + + + +
HooksList of hooks you can use with irc:hook.
UserTable with information about a user.
+ + + +
+
+ + + +

Functions

+
+ + + +
irc:connect (server, port, timeout)
+
+Connect irc to an IRC server. + + +

Parameters

+
    + +
  • + server: Server address. +
  • + +
  • + port: Server port. [default 6667] +
  • + +
  • + timeout: Connection timeout value in seconds. [default 30] +
  • + +
+ + + + + + + + +
+ + + + +
irc:disconnect (message)
+
+Disconnect irc from the server. + + +

Parameters

+
    + +
  • + message: Quit message. +
  • + +
+ + + + + + + + +
+ + + + +
irc:hook (name, id, f)
+
+Hook a function to an event. + + +

Parameters

+
    + +
  • + name: Name of event. +
  • + +
  • + id: Unique tag. +
  • + +
  • + f: Callback function. [defaults to id] +
  • + +
+ + + + + + + + +

See also:

+ + +
+ + + + +
irc:join (channel, key)
+
+Join a channel. + + +

Parameters

+
    + +
  • + channel: Channel to join. +
  • + +
  • + key: Channel password. [optional] +
  • + +
+ + + + + + + + +
+ + + + +
irc:part (channel)
+
+Leave a channel. + + +

Parameters

+
    + +
  • + channel: Channel to leave. +
  • + +
+ + + + + + + + +
+ + + + +
irc:send (fmt, ...)
+
+Send a raw line of IRC to the server. + + +

Parameters

+
    + +
  • + fmt: Line to be sent, excluding newline characters. +
  • + +
  • + ...: Format parameters for fmt, with string.format semantics. +
  • + +
+ + + + + + + + +
+ + + + +
irc:sendChat (target, message)
+
+Send a message to a channel or user. + + +

Parameters

+
    + +
  • + target: Nick or channel to send to. +
  • + +
  • + message: Message to send. +
  • + +
+ + + + + + + + +
+ + + + +
irc:sendNotice (target, message)
+
+Send a notice to a channel or user. + + +

Parameters

+
    + +
  • + target: Nick or channel to send to. +
  • + +
  • + message: Notice to send. +
  • + +
+ + + + + + + + +
+ + + + +
irc:setMode (t)
+
+Add/remove modes for a channel or nick. + + +

Parameters

+
    + +
  • + t: Table with fields target, nick, add and/or rem. target or nick specifies the user or channel to add/remove modes. add is a list of modes to add to the user or channel. rem is a list of modes to remove from the user or channel. +
  • + +
+ + + + +

Usage:

+Example which sets +m (moderated) for #channel:
irc:setMode{target = "#channel", add = "m"} + + + + + +
+ + + + +
irc:think ()
+
+Handle incoming data for irc, 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. + + + + + + + + + +
+ + + + +
irc:trackUsers (b)
+
+Turn user information tracking on or off. User tracking is enabled by default. + + +

Parameters

+
    + +
  • + b: Boolean whether or not to track user information. +
  • + +
+ + + + + + + + +
+ + + + +
irc:unhook (name, id)
+
+Remove previous hooked callback. + + +

Parameters

+
    + +
  • + name: Name of event. +
  • + +
  • + id: Unique tag. +
  • + +
+ + + + + + + + +
+ + + + +
irc:whois (nick)
+
+Look up user info. + + +

Parameters

+
    + +
  • + nick: Nick of user to query. +
  • + +
+ + + + + + +

Return value:

+Table with fields userinfo, node, channels and account. + + + +
+ + + + +
new (user)
+
+Create a new IRC object. Use irc:connect to connect to a server. + + +

Parameters

+
    + +
  • + user: Table with fields nick, username and realname. The nick field is required. +
  • + +
+ + + + + + +

Return value:

+Returns a new irc object. + + + +
+ + +
+ + + + +

Tables

+
+ +
Hooks
+
List of hooks you can use with irc:hook. The parameter list describes the parameters passed to the callback function.
  • OnDisconnect(message, errorOccurred)
  • OnChat(user, channel, message)
  • OnNotice(user, channel, message)
  • OnJoin(user, channel)*
  • OnPart(user, channel)*
  • OnQuit(user, message)
  • NickChange(user, newnick)*
  • NameList(channel, names)
* Event also invoked for yourself. + + + +
+ + +
User
+
Table with information about a user.
  • nick - User nickname. Always present.
  • username - User username.
  • host - User hostname.
  • realname - User real name.
  • access - User access, available in channel-oriented callbacks. Can be '+', '@', and others, depending on the server.
Apart from nick, fields may be missing. To fill them in, enable user tracking and use irc:whois. + + + +
+ + +
+ + + +
+ +
+ +
+

Valid XHTML 1.0!

+
+ +
+ +