mirror of
https://github.com/ShadowNinja/LuaIRC.git
synced 2025-01-09 17:40:29 +01:00
Use Message objects internally and pass one to Do* hooks
This commit is contained in:
parent
e958a7242a
commit
7024ad5512
@ -108,7 +108,7 @@ function irc:setMode(t)
|
|||||||
|
|
||||||
--internal
|
--internal
|
||||||
function irc:invoke(name, ...)
|
function irc:invoke(name, ...)
|
||||||
function irc:handle(prefix, cmd, params)
|
function irc:handle(msg)
|
||||||
function irc:shutdown()
|
function irc:shutdown()
|
||||||
|
|
||||||
--- Table with connection information.
|
--- Table with connection information.
|
||||||
@ -123,17 +123,23 @@ function irc:shutdown()
|
|||||||
-- @name Connection
|
-- @name Connection
|
||||||
-- @class table
|
-- @class table
|
||||||
|
|
||||||
--- Class representing an IRC message.
|
--- Class representing an IRC message. Objects of this class may contain the following fields:
|
||||||
|
-- <ul>
|
||||||
|
-- <li><code>prefix</code> - Prefix of the message.</li>
|
||||||
|
-- <li><code>user</code> - A User object describing the sender of the message.</li>
|
||||||
|
-- <li><code>command</code> - The IRC command.</li>
|
||||||
|
-- <li><code>args</code> - A list of the command arguments.</li>
|
||||||
|
-- </ul>
|
||||||
|
-- Fields may be missing. The only guarantee is that <code>args</code> is a table.
|
||||||
|
-- Messages have the following methods:
|
||||||
-- <ul>
|
-- <ul>
|
||||||
-- <li><code>sender</code></li>
|
|
||||||
-- <li><code>command</code></li>
|
|
||||||
-- <li><code>args</code></li>
|
|
||||||
-- <li><code>toRFC1459()</code></li>
|
-- <li><code>toRFC1459()</code></li>
|
||||||
-- </ul>
|
-- </ul>
|
||||||
-- @name Message
|
-- @name Message
|
||||||
-- @class table
|
-- @class table
|
||||||
|
|
||||||
--- List of hooks you can use with irc:hook. The parameter list describes the parameters passed to the callback function.
|
--- List of hooks you can use with irc:hook.
|
||||||
|
-- The parameter list describes the parameters passed to the callback function.
|
||||||
-- <ul>
|
-- <ul>
|
||||||
-- <li><code>PreRegister(connection)</code>Useful for CAP commands and SASL.</li>
|
-- <li><code>PreRegister(connection)</code>Useful for CAP commands and SASL.</li>
|
||||||
-- <li><code>OnRaw(line) - (any non false/nil return value assumes line handled and will not be further processed)</code></li>
|
-- <li><code>OnRaw(line) - (any non false/nil return value assumes line handled and will not be further processed)</code></li>
|
||||||
@ -152,7 +158,7 @@ function irc:shutdown()
|
|||||||
-- <li><code>OnUserMode(modes)</code></li>
|
-- <li><code>OnUserMode(modes)</code></li>
|
||||||
-- <li><code>OnChannelMode(user, channel, modes)</code></li>
|
-- <li><code>OnChannelMode(user, channel, modes)</code></li>
|
||||||
-- <li><code>OnModeChange(user, target, modes, ...)</code>* ('...' contains mode options such as banmasks)</li>
|
-- <li><code>OnModeChange(user, target, modes, ...)</code>* ('...' contains mode options such as banmasks)</li>
|
||||||
-- <li><code>DoX(user, ...)</code>'X' is any IRC command or numeric with the first letter capitalized (eg, DoPing and Do001)</li>
|
-- <li><code>DoX(msg)</code>'X' is any IRC command or numeric with the first letter capitalized (eg, DoPing and Do001)</li>
|
||||||
-- </ul>
|
-- </ul>
|
||||||
-- * Event also invoked for yourself.
|
-- * Event also invoked for yourself.
|
||||||
-- † Channel passed only when user tracking is enabled
|
-- † Channel passed only when user tracking is enabled
|
||||||
@ -161,12 +167,14 @@ function irc:shutdown()
|
|||||||
|
|
||||||
--- Table with information about a user.
|
--- Table with information about a user.
|
||||||
-- <ul>
|
-- <ul>
|
||||||
-- <li><code>nick</code> - User nickname. Always present.</li>
|
-- <li><code>server</code> - Server name.</li>
|
||||||
|
-- <li><code>nick</code> - User nickname.</li>
|
||||||
-- <li><code>username</code> - User username.</li>
|
-- <li><code>username</code> - User username.</li>
|
||||||
-- <li><code>host</code> - User hostname.</li>
|
-- <li><code>host</code> - User hostname.</li>
|
||||||
-- <li><code>realname</code> - User real name.</li>
|
-- <li><code>realname</code> - User real name.</li>
|
||||||
-- <li><code>access</code> - User access, available in channel-oriented callbacks. A table containing boolean fields for each access mode that the server supports. Eg: 'o', and 'v'.</li>
|
-- <li><code>access</code> - User access, available in channel-oriented callbacks. A table containing boolean fields for each access mode that the server supports. Eg: 'o', and 'v'.</li>
|
||||||
-- </ul>
|
-- </ul>
|
||||||
-- Apart from <code>nick</code>, fields may be missing. To fill them in, enable user tracking and use irc:whois.
|
-- Fields may be missing. To fill them in, enable user tracking and use irc:whois.
|
||||||
-- @name User
|
-- @name User
|
||||||
-- @class table
|
-- @class table
|
||||||
|
|
||||||
|
205
handlers.lua
205
handlers.lua
@ -2,82 +2,87 @@ local pairs = pairs
|
|||||||
local error = error
|
local error = error
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
local table = table
|
local table = table
|
||||||
|
local unpack = unpack
|
||||||
|
|
||||||
module "irc"
|
module "irc"
|
||||||
|
|
||||||
handlers = {}
|
handlers = {}
|
||||||
|
|
||||||
handlers["PING"] = function(o, user, query)
|
handlers["PING"] = function(conn, msg)
|
||||||
o:send(Message("PONG", {query}))
|
conn:send(Message("PONG", msg.args))
|
||||||
end
|
end
|
||||||
|
|
||||||
handlers["001"] = function(o, user, me)
|
handlers["001"] = function(conn, msg)
|
||||||
o.authed = true
|
conn.authed = true
|
||||||
o.nick = me
|
conn.nick = msg.args[1]
|
||||||
end
|
end
|
||||||
|
|
||||||
handlers["PRIVMSG"] = function(o, user, channel, message)
|
handlers["PRIVMSG"] = function(conn, msg)
|
||||||
o:invoke("OnChat", user, channel, message)
|
conn:invoke("OnChat", msg.user, msg.args[1], msg.args[2])
|
||||||
end
|
end
|
||||||
|
|
||||||
handlers["NOTICE"] = function(o, user, channel, message)
|
|
||||||
o:invoke("OnNotice", user, channel, message)
|
handlers["NOTICE"] = function(conn, msg)
|
||||||
|
conn:invoke("OnNotice", msg.user, msg.args[1], msg.args[2])
|
||||||
end
|
end
|
||||||
|
|
||||||
handlers["JOIN"] = function(o, user, channel)
|
handlers["JOIN"] = function(conn, msg)
|
||||||
if o.track_users then
|
local channel = msg.args[1]
|
||||||
if user.nick == o.nick then
|
if conn.track_users then
|
||||||
o.channels[channel] = {users = {}}
|
if msg.user.nick == conn.nick then
|
||||||
|
conn.channels[channel] = {users = {}}
|
||||||
else
|
else
|
||||||
o.channels[channel].users[user.nick] = user
|
conn.channels[channel].users[msg.user.nick] = user
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
o:invoke("OnJoin", user, channel)
|
conn:invoke("OnJoin", msg.user, msg.args[1])
|
||||||
end
|
end
|
||||||
|
|
||||||
handlers["PART"] = function(o, user, channel, reason)
|
handlers["PART"] = function(conn, msg)
|
||||||
if o.track_users then
|
local channel = msg.args[1]
|
||||||
if user.nick == o.nick then
|
if conn.track_users then
|
||||||
o.channels[channel] = nil
|
if msg.user.nick == conn.nick then
|
||||||
|
conn.channels[channel] = nil
|
||||||
else
|
else
|
||||||
o.channels[channel].users[user.nick] = nil
|
conn.channels[channel].users[msg.user.nick] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
o:invoke("OnPart", user, channel, reason)
|
conn:invoke("OnPart", msg.user, msg.args[1], msg.args[2])
|
||||||
end
|
end
|
||||||
|
|
||||||
handlers["QUIT"] = function(o, user, msg)
|
handlers["QUIT"] = function(conn, msg)
|
||||||
if o.track_users then
|
if conn.track_users then
|
||||||
for channel, v in pairs(o.channels) do
|
for chanName, chan in pairs(conn.channels) do
|
||||||
v.users[user.nick] = nil
|
chan.users[msg.user.nick] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
o:invoke("OnQuit", user, msg)
|
conn:invoke("OnQuit", msg.user, msg.args[1], msg.args[2])
|
||||||
end
|
end
|
||||||
|
|
||||||
handlers["NICK"] = function(o, user, newnick)
|
handlers["NICK"] = function(conn, msg)
|
||||||
if o.track_users then
|
local newNick = msg.args[1]
|
||||||
for channel, v in pairs(o.channels) do
|
if conn.track_users then
|
||||||
local users = v.users
|
for chanName, chan in pairs(conn.channels) do
|
||||||
local oldinfo = users[user.nick]
|
local users = chan.users
|
||||||
|
local oldinfo = users[msg.user.nick]
|
||||||
if oldinfo then
|
if oldinfo then
|
||||||
users[newnick] = oldinfo
|
users[newNick] = oldinfo
|
||||||
users[user.nick] = nil
|
users[msg.user.nick] = nil
|
||||||
o:invoke("NickChange", user, newnick, channel)
|
conn:invoke("NickChange", msg.user, newNick, chanName)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
o:invoke("NickChange", user, newnick)
|
conn:invoke("NickChange", msg.user, newNick)
|
||||||
end
|
end
|
||||||
if user.nick == o.nick then
|
if msg.user.nick == conn.nick then
|
||||||
o.nick = newnick
|
conn.nick = newnick
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function needNewNick(o, user, target, badnick)
|
local function needNewNick(conn, msg)
|
||||||
local newnick = o.nickGenerator(badnick)
|
local newnick = conn.nickGenerator(msg.args[2])
|
||||||
o:send(msgs.nick(newnick))
|
conn:send(msgs.nick(newnick))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- ERR_ERRONEUSNICKNAME (Misspelt but remains for historical reasons)
|
-- ERR_ERRONEUSNICKNAME (Misspelt but remains for historical reasons)
|
||||||
@ -87,111 +92,119 @@ handlers["432"] = needNewNick
|
|||||||
handlers["433"] = needNewNick
|
handlers["433"] = needNewNick
|
||||||
|
|
||||||
-- RPL_ISUPPORT
|
-- RPL_ISUPPORT
|
||||||
handlers["005"] = function(o, user, nick, ...)
|
handlers["005"] = function(conn, msg)
|
||||||
local list = {...}
|
local arglen = #msg.args
|
||||||
local listlen = #list
|
-- Skip first and last parameters (nick and info)
|
||||||
-- Skip last parameter (info)
|
for i = 2, arglen - 1 do
|
||||||
for i = 1, listlen - 1 do
|
local item = msg.args[i]
|
||||||
local item = list[i]
|
|
||||||
local pos = item:find("=")
|
local pos = item:find("=")
|
||||||
if pos then
|
if pos then
|
||||||
o.supports[item:sub(1, pos - 1)] = item:sub(pos + 1)
|
conn.supports[item:sub(1, pos - 1)] = item:sub(pos + 1)
|
||||||
else
|
else
|
||||||
o.supports[item] = true
|
conn.supports[item] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- RPL_MOTDSTART
|
-- RPL_MOTDSTART
|
||||||
handlers["375"] = function(o, user, info)
|
handlers["375"] = function(conn, msg)
|
||||||
o.motd = ""
|
conn.motd = ""
|
||||||
end
|
end
|
||||||
|
|
||||||
-- RPL_MOTD
|
-- RPL_MOTD
|
||||||
handlers["372"] = function(o, user, nick, line)
|
handlers["372"] = function(conn, msg)
|
||||||
-- MOTD lines have a "- " prefix, strip it.
|
-- MOTD lines have a "- " prefix, strip it.
|
||||||
o.motd = o.motd..line:sub(3)..'\n'
|
conn.motd = conn.motd .. msg.args[2]:sub(3) .. '\n'
|
||||||
end
|
end
|
||||||
|
|
||||||
--NAMES list
|
-- NAMES list
|
||||||
handlers["353"] = function(o, user, me, chanType, channel, names)
|
handlers["353"] = function(conn, msg)
|
||||||
if o.track_users then
|
local chanType = msg.args[2]
|
||||||
o.channels[channel] = o.channels[channel] or {users = {}, type = chanType}
|
local channel = msg.args[3]
|
||||||
|
local names = msg.args[4]
|
||||||
|
if conn.track_users then
|
||||||
|
conn.channels[channel] = conn.channels[channel] or {users = {}, type = chanType}
|
||||||
|
|
||||||
local users = o.channels[channel].users
|
local users = conn.channels[channel].users
|
||||||
for nick in names:gmatch("(%S+)") do
|
for nick in names:gmatch("(%S+)") do
|
||||||
local access, name = parseNick(o, nick)
|
local access, name = parseNick(conn, nick)
|
||||||
users[name] = {access = access}
|
users[name] = {access = access}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--end of NAMES
|
-- End of NAMES list
|
||||||
handlers["366"] = function(o, user, me, channel, msg)
|
handlers["366"] = function(conn, msg)
|
||||||
if o.track_users then
|
if conn.track_users then
|
||||||
o:invoke("NameList", channel, msg)
|
conn:invoke("NameList", msg.args[2], msg.args[3])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--no topic
|
-- No topic
|
||||||
handlers["331"] = function(o, user, me, channel)
|
handlers["331"] = function(conn, msg)
|
||||||
o:invoke("OnTopic", channel, nil)
|
conn:invoke("OnTopic", msg.args[2], nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
--new topic
|
handlers["TOPIC"] = function(conn, msg)
|
||||||
handlers["TOPIC"] = function(o, user, channel, topic)
|
conn:invoke("OnTopic", msg.args[1], msg.args[2])
|
||||||
o:invoke("OnTopic", channel, topic)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
handlers["332"] = function(o, user, me, channel, topic)
|
handlers["332"] = function(conn, msg)
|
||||||
o:invoke("OnTopic", channel, topic)
|
conn:invoke("OnTopic", msg.args[2], msg.args[3])
|
||||||
end
|
end
|
||||||
|
|
||||||
--topic creation info
|
-- Topic creation info
|
||||||
handlers["333"] = function(o, user, me, channel, nick, time)
|
handlers["333"] = function(conn, msg)
|
||||||
o:invoke("OnTopicInfo", channel, nick, tonumber(time))
|
conn:invoke("OnTopicInfo", msg.args[2], msg.args[3], tonumber(msg.args[4]))
|
||||||
end
|
end
|
||||||
|
|
||||||
handlers["KICK"] = function(o, user, channel, kicked, reason)
|
handlers["KICK"] = function(conn, msg)
|
||||||
o:invoke("OnKick", channel, kicked, user, reason)
|
conn:invoke("OnKick", msg.args[1], msg.args[2], msg.user, msg.args[3])
|
||||||
end
|
end
|
||||||
|
|
||||||
--RPL_UMODEIS
|
-- RPL_UMODEIS
|
||||||
--To answer a query about a client's own mode, RPL_UMODEIS is sent back
|
-- To answer a query about a client's own mode, RPL_UMODEIS is sent back
|
||||||
handlers["221"] = function(o, user, user, modes)
|
handlers["221"] = function(conn, msg)
|
||||||
o:invoke("OnUserMode", modes)
|
conn:invoke("OnUserMode", msg.args[2])
|
||||||
end
|
end
|
||||||
|
|
||||||
--RPL_CHANNELMODEIS
|
-- RPL_CHANNELMODEIS
|
||||||
--The result from common irc servers differs from that defined by the rfc
|
-- The result from common irc servers differs from that defined by the rfc
|
||||||
handlers["324"] = function(o, user, user, channel, modes)
|
handlers["324"] = function(conn, msg)
|
||||||
o:invoke("OnChannelMode", channel, modes)
|
conn:invoke("OnChannelMode", msg.args[2], msg.args[3])
|
||||||
end
|
end
|
||||||
|
|
||||||
handlers["MODE"] = function(o, user, target, modes, ...)
|
handlers["MODE"] = function(conn, msg)
|
||||||
if o.track_users and target ~= o.nick then
|
local target = msg.args[1]
|
||||||
|
local modes = msg.args[2]
|
||||||
|
local optList = {}
|
||||||
|
for i = 3, #msg.args do
|
||||||
|
table.insert(optList, msg.args[i])
|
||||||
|
end
|
||||||
|
if conn.track_users and target ~= conn.nick then
|
||||||
local add = true
|
local add = true
|
||||||
local optList = {...}
|
local argNum = 1
|
||||||
updatePrefixModes(o)
|
updatePrefixModes(conn)
|
||||||
for c in modes:gmatch(".") do
|
for c in modes:gmatch(".") do
|
||||||
if c == "+" then add = true
|
if c == "+" then add = true
|
||||||
elseif c == "-" then add = false
|
elseif c == "-" then add = false
|
||||||
elseif o.modeprefix[c] then
|
elseif conn.modeprefix[c] then
|
||||||
local nick = table.remove(optList, 1)
|
local nick = optList[argNum]
|
||||||
local access = o.channels[target].users[nick].access
|
argNum = argNum + 1
|
||||||
access[o.modeprefix[c]] = add
|
local access = conn.channels[target].users[nick].access
|
||||||
|
access[conn.modeprefix[c]] = add
|
||||||
if c == "o" then access.op = add
|
if c == "o" then access.op = add
|
||||||
elseif c == "v" then access.voice = add
|
elseif c == "v" then access.voice = add
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
o:invoke("OnModeChange", user, target, modes, ...)
|
conn:invoke("OnModeChange", msg.user, target, modes, unpack(optList))
|
||||||
end
|
end
|
||||||
|
|
||||||
handlers["ERROR"] = function(o, user, message)
|
handlers["ERROR"] = function(conn, msg)
|
||||||
o:invoke("OnDisconnect", message, true)
|
conn:invoke("OnDisconnect", msg.args[1], true)
|
||||||
o:shutdown()
|
conn:shutdown()
|
||||||
error(message, 3)
|
error(msg.args[1], 3)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
19
init.lua
19
init.lua
@ -68,7 +68,7 @@ meta_preconnect.unhook = meta.unhook
|
|||||||
function meta:invoke(name, ...)
|
function meta:invoke(name, ...)
|
||||||
local hooks = self.hooks[name]
|
local hooks = self.hooks[name]
|
||||||
if hooks then
|
if hooks then
|
||||||
for id,f in pairs(hooks) do
|
for id, f in pairs(hooks) do
|
||||||
if f(...) then
|
if f(...) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -184,13 +184,12 @@ end
|
|||||||
|
|
||||||
local handlers = handlers
|
local handlers = handlers
|
||||||
|
|
||||||
function meta:handle(prefix, cmd, params)
|
function meta:handle(msg)
|
||||||
local user = parsePrefix(prefix)
|
local handler = handlers[msg.command]
|
||||||
local handler = handlers[cmd]
|
|
||||||
if handler then
|
if handler then
|
||||||
handler(self, user, unpack(params))
|
handler(self, msg)
|
||||||
end
|
end
|
||||||
self:invoke("Do"..capitalize(cmd), user, unpack(params))
|
self:invoke("Do"..capitalize(msg.command), msg)
|
||||||
end
|
end
|
||||||
|
|
||||||
local whoisHandlers = {
|
local whoisHandlers = {
|
||||||
@ -209,15 +208,15 @@ function meta:whois(nick)
|
|||||||
while true do
|
while true do
|
||||||
local line = getline(self, 3)
|
local line = getline(self, 3)
|
||||||
if line then
|
if line then
|
||||||
local prefix, cmd, args = parse(line)
|
local msg = parse(line)
|
||||||
|
|
||||||
local handler = whoisHandlers[cmd]
|
local handler = whoisHandlers[msg.command]
|
||||||
if handler then
|
if handler then
|
||||||
result[handler] = args
|
result[handler] = msg.args
|
||||||
elseif cmd == "318" then
|
elseif cmd == "318" then
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
self:handle(prefix, cmd, args)
|
self:handle(msg)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
52
util.lua
52
util.lua
@ -10,44 +10,31 @@ local random = math.random
|
|||||||
|
|
||||||
module "irc"
|
module "irc"
|
||||||
|
|
||||||
--protocol parsing
|
-- Protocol parsing
|
||||||
function parse(line)
|
function parse(line)
|
||||||
local prefix
|
local msg = Message()
|
||||||
local lineStart = 1
|
|
||||||
if line:sub(1,1) == ":" then
|
if line:sub(1, 1) == ":" then
|
||||||
local space = line:find(" ")
|
local space = line:find(" ")
|
||||||
prefix = line:sub(2, space-1)
|
msg.prefix = line:sub(2, space - 1)
|
||||||
lineStart = space
|
msg.user = parsePrefix(msg.prefix)
|
||||||
|
line = line:sub(space + 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
local _, trailToken = line:find("%s+:", lineStart)
|
local pos
|
||||||
local lineStop = line:len()
|
msg.command, pos = line:match("(%S+)()")
|
||||||
local trailing
|
line = line:sub(pos)
|
||||||
if trailToken then
|
|
||||||
trailing = line:sub(trailToken + 1)
|
|
||||||
lineStop = trailToken - 2
|
|
||||||
end
|
|
||||||
|
|
||||||
local params = {}
|
for pos, param in line:gmatch("()(%S+)") do
|
||||||
|
if param:sub(1, 1) == ":" then
|
||||||
local _, cmdEnd, cmd = line:find("(%S+)", lineStart)
|
param = line:sub(pos + 1)
|
||||||
local pos = cmdEnd + 1
|
table.insert(msg.args, param)
|
||||||
while true do
|
|
||||||
local _, stop, param = line:find("(%S+)", pos)
|
|
||||||
|
|
||||||
if not param or stop > lineStop then
|
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
table.insert(msg.args, param)
|
||||||
pos = stop + 1
|
|
||||||
params[#params + 1] = param
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if trailing then
|
return msg
|
||||||
params[#params + 1] = trailing
|
|
||||||
end
|
|
||||||
|
|
||||||
return prefix, cmd, params
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function parseNick(conn, nick)
|
function parseNick(conn, nick)
|
||||||
@ -71,8 +58,9 @@ end
|
|||||||
|
|
||||||
function parsePrefix(prefix)
|
function parsePrefix(prefix)
|
||||||
local user = {}
|
local user = {}
|
||||||
if prefix then
|
user.nick, user.username, user.host = prefix:match("^(.+)!(.+)@(.+)$")
|
||||||
user.nick, user.username, user.host = prefix:match("^(.+)!(.+)@(.+)$")
|
if not user.nick and prefix:find(".", 1, true) then
|
||||||
|
user.server = prefix
|
||||||
end
|
end
|
||||||
return user
|
return user
|
||||||
end
|
end
|
||||||
@ -163,7 +151,7 @@ function capitalize(text)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function split(str, sep)
|
function split(str, sep)
|
||||||
t = {}
|
local t = {}
|
||||||
for s in str:gmatch("%S+") do
|
for s in str:gmatch("%S+") do
|
||||||
table.insert(t, s)
|
table.insert(t, s)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user