Merge branch 'master' of git://github.com/jsimmons/LuaIRC

This commit is contained in:
Jakob Ovrum 2010-07-21 09:39:50 +09:00
commit c4d7278c4b
2 changed files with 12 additions and 9 deletions

View File

@ -139,6 +139,7 @@ function irc:shutdown()
-- <li><code>OnKick(channel, nick, kicker, reason)</code>* (kicker is a <code>user</code> table)</li>
-- <li><code>OnUserModeIs(modes)</code></li>
-- <li><code>OnChannelModeIs(user, channel, modes)</code></li>
-- <li><code>OnModeChange(user, target, modes)</code>*</li>
-- </ul>
-- * Event also invoked for yourself.
-- † Channel passed only when user tracking is enabled

View File

@ -120,8 +120,8 @@ function meta_preconnect:connect(_host, _port)
self:send("PASS %s", password)
end
self:send("USER %s 0 * :%s", self.username, self.realname)
self:send("NICK %s", self.nick)
self:send("USER %s 0 * :%s", self.username, self.realname)
self.channels = {}
@ -149,15 +149,13 @@ end
local function getline(self, errlevel)
local line, err = self.socket:receive("*l")
if line then
return line
end
if err ~= "timeout" and err ~= "wantread" then
if not line and err ~= "timeout" and err ~= "wantread" then
self:invoke("OnDisconnect", err, true)
self:close()
self:shutdown()
error(err, errlevel)
end
return line
end
function meta:think()
@ -288,14 +286,18 @@ end
--RPL_UMODEIS
--To answer a query about a client's own mode, RPL_UMODEIS is sent back
handlers["221"] = function(o, prefix, modes)
handlers["221"] = function(o, prefix, user, modes)
o:invoke("OnUserModeIs", modes)
end
--RPL_CHANNELMODEIS
--The result from common irc servers differs from that defined by the rfc
handlers["324"] = function(o, prefix, user, channel, modes)
o:invoke("OnChannelModeIs", user, channel, modes)
o:invoke("OnChannelModeIs", channel, modes)
end
handlers["MODE"] = function(o, prefix, target, modes)
o:invoke("OnModeChange", parsePrefix(prefix), target, modes)
end
handlers["ERROR"] = function(o, prefix, message)