base.assert(serverinfo.channels[chan],
"Received user information about unknown channel: " .. chan)
serverinfo.channels[chan]._chanmode = constants.chanmodes[chanmode]
- local users = misc.split(userlist)
+ local users = misc._split(userlist)
for k,v in base.ipairs(users) do
if v:sub(1, 1) == "@" or v:sub(1, 1) == "+" then
local nick = v:sub(2)
- serverinfo.channels[chan]:add_user(nick, v:sub(1, 1))
+ serverinfo.channels[chan]:_add_user(nick, v:sub(1, 1))
else
- serverinfo.channels[chan]:add_user(v)
+ serverinfo.channels[chan]:_add_user(v)
end
end
end
base.assert(serverinfo.channels[chan],
"Received user information about unknown channel: " .. chan)
if not serverinfo.channels[chan].join_complete then
- misc.try_call(on_me_join, serverinfo.channels[chan])
+ misc._try_call(on_me_join, serverinfo.channels[chan])
serverinfo.channels[chan].join_complete = true
end
end
if not serverinfo.connected then
serverinfo.connected = true
serverinfo.connecting = false
- misc.try_call(on_connect)
+ misc._try_call(on_connect)
end
end
-- }}}
-- on_rpl_whoisuser {{{
function handlers.on_rpl_whoisuser(from, nick, user, host, star, realname)
- nick = nick:lower()
- requestinfo.whois[nick].user = user
- requestinfo.whois[nick].host = host
- requestinfo.whois[nick].realname = realname
+ local lnick = nick:lower()
+ requestinfo.whois[lnick].nick = nick
+ requestinfo.whois[lnick].user = user
+ requestinfo.whois[lnick].host = host
+ requestinfo.whois[lnick].realname = realname
end
-- }}}
if not requestinfo.whois[nick].channels then
requestinfo.whois[nick].channels = {}
end
- for _, channel in base.ipairs(misc.split(channel_list)) do
+ for _, channel in base.ipairs(misc._split(channel_list)) do
table.insert(requestinfo.whois[nick].channels, channel)
end
end
if to:sub(1, 1) == "#" then
base.assert(serverinfo.channels[to],
"Received channel msg from unknown channel: " .. to)
- misc.try_call(on_channel_act, serverinfo.channels[to], from, message)
+ misc._try_call(on_channel_act, serverinfo.channels[to], from, message)
else
- misc.try_call(on_private_act, from, message)
+ misc._try_call(on_private_act, from, message)
end
end
-- }}}
-- TODO: can we not have this handler be registered unless the dcc module is
-- loaded?
function ctcp_handlers.on_dcc(from, to, message)
- local type, argument, address, port, size = base.unpack(misc.split(message, " ", nil, '"', '"'))
+ local type, argument, address, port, size = base.unpack(misc._split(message, " ", nil, '"', '"'))
if type == "SEND" then
- if misc.try_call(on_dcc, from, to, argument, address, port, size) then
- dcc.accept(argument, address, port)
+ if misc._try_call(on_dcc, from, to, argument, address, port, size) then
+ dcc._accept(argument, address, port)
end
elseif type == "CHAT" then
-- TODO: implement this? do people ever use this?
-- on_rpl_version {{{
function ctcp_handlers.on_rpl_version(from, to, version)
- local cb = table.remove(icallbacks.ctcp_version[from], 1)
+ local lfrom = from:lower()
+ local cb = table.remove(icallbacks.ctcp_version[lfrom], 1)
cb({version = version, nick = from})
- if #icallbacks.ctcp_version[from] > 0 then say(from, {"VERSION"})
- else icallbacks.ctcp_version[from] = nil
+ if #icallbacks.ctcp_version[lfrom] > 0 then say(from, {"VERSION"})
+ else icallbacks.ctcp_version[lfrom] = nil
end
end
-- }}}
-- on_rpl_ping {{{
function ctcp_handlers.on_rpl_ping(from, to, timestamp)
- local cb = table.remove(icallbacks.ctcp_ping[from], 1)
+ local lfrom = from:lower()
+ local cb = table.remove(icallbacks.ctcp_ping[lfrom], 1)
cb({time = os.time() - timestamp, nick = from})
- if #icallbacks.ctcp_ping[from] > 0 then say(from, {"PING " .. os.time()})
- else icallbacks.ctcp_ping[from] = nil
+ if #icallbacks.ctcp_ping[lfrom] > 0 then say(from, {"PING " .. os.time()})
+ else icallbacks.ctcp_ping[lfrom] = nil
end
end
-- }}}
-- on_rpl_time {{{
function ctcp_handlers.on_rpl_time(from, to, time)
- local cb = table.remove(icallbacks.ctcp_time[from], 1)
+ local lfrom = from:lower()
+ local cb = table.remove(icallbacks.ctcp_time[lfrom], 1)
cb({time = time, nick = from})
- if #icallbacks.ctcp_time[from] > 0 then say(from, {"TIME"})
- else icallbacks.ctcp_time[from] = nil
+ if #icallbacks.ctcp_time[lfrom] > 0 then say(from, {"TIME"})
+ else icallbacks.ctcp_time[lfrom] = nil
end
end
-- }}}
_register_socket(irc_sock, 'r', incoming_message)
if args.pass then send("PASS", args.pass) end
send("NICK", nick)
- send("USER", username, (irc_sock:getsockname()), network, realname)
+ send("USER", username, get_ip(), network, realname)
begin_main_loop()
end
-- }}}
-- @param nick User to request WHOIS information about
function whois(cb, nick)
nick = nick:lower()
- requestinfo.whois[nick] = {nick = nick}
+ requestinfo.whois[nick] = {}
if not icallbacks.whois[nick] then
icallbacks.whois[nick] = {cb}
send("WHOIS", nick)
if base.type(v) == "string" then
arg = v
elseif base.type(v) == "table" then
- arg = ctcp.ctcp_quote(table.concat(v, " "))
+ arg = ctcp._ctcp_quote(table.concat(v, " "))
end
if i == #{...} then
arg = ":" .. arg
end
message = message .. " " .. arg
end
- message = ctcp.low_quote(message)
+ message = ctcp._low_quote(message)
-- we just truncate for now. -2 to account for the \r\n
message = message:sub(1, constants.IRC_MAX_MSG - 2)
- irc_debug.message("SEND", message)
+ irc_debug._message("SEND", message)
irc_sock:send(message .. "\r\n")
end
-- }}}
-- @see irc.channel
function channels()
return function(state, arg)
- return misc.value_iter(state, arg,
- function(v)
- return v.join_complete
- end)
+ return misc._value_iter(state, arg,
+ function(v)
+ return v.join_complete
+ end)
end,
serverinfo.channels,
nil