--- LuaIRC is a low-level IRC library for Lua.
-- All functions raise Lua exceptions on error.
module "irc"
--- Create a new IRC object.
-- The user
parameter can contain fields nick
, username
and realname
.
-- The nick
field is required.
-- Returns a new irc
object.
function new(user)
--- 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.
function irc:hook(name, id, f)
--- Removes previous hooked callback with the tag id
from event name
.
function irc:unhook(name, id)
--internal
function irc:invoke(name, ...)
--- Connects irc
to server:port
, with the connection timeout value timeout
.
function irc:connect(server, port, timeout)
--- Disconnects irc
from the server, with the quit message message
.
function irc:disconnect(message)
--internal
function irc:shutdown()
--- Handles incoming data for irc
, and invokes previously hooked callbacks based on the new server input.
-- You should call this in some kind of main loop, or at least often enough not to time out.
function irc:think()
--internal
function irc:handle(prefix, cmd, params)
--- Sends a WHOIS lookup request for nick
.
-- Returns a table with the fields userinfo
, node
, channels
and account
.
function irc:whois(nick)
--- Sends a raw line of IRC to the server.
-- fmt
is the line to be sent, without the newline characters.
-- fmt
can be a format string taking the parameters ...
, with string.format
semantics.
function irc:send(fmt, ...)
--- Sends the message msg
to target
.
-- target
should be either a channel or nick.
function irc:sendChat(target, msg)
--- Sends the notice msg
to target
.
-- target
should be either a channel or nick.
function irc:sendNotice(target, msg)
--- Joins channel
, optionally with the channel password key
.
function irc:join(channel, key)
--- Leaves channel
.
function irc:part(channel)
--- Specifies whether to cache user information or not with the boolean b
.
function irc:trackUsers(b)
--- Adds and/or removes modes for a channel or nick.
-- Either t.target
or t.nick
specifies the channel or nick to add/remove modes.
-- t.add
is a list of modes to add to the target.
-- t.rem
is a list of modes to remove from the target.
-- Example which sets +m (moderated) for #channel: irc:setMode{target = "#channel", add = "m"}
function irc:setMode(t)