diff --git a/LICENSE.txt b/LICENSE.txt index bd1b7dd..0a68ca1 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ ---[[ +--[[ Lua IRC library Copyright (c) 2010 Jakob Ovrum @@ -22,4 +22,5 @@ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - OTHER DEALINGS IN THE SOFTWARE.]] \ No newline at end of file + OTHER DEALINGS IN THE SOFTWARE.]] + diff --git a/README.markdown b/README.markdown index d70d6d2..5fc5702 100644 --- a/README.markdown +++ b/README.markdown @@ -8,6 +8,10 @@ Dependencies * [LuaSocket](http://w3.impa.br/~diego/software/luasocket/) +**Only required if you want to make use of the TLS support** + + * [LuaSec](http://www.inf.puc-rio.br/~brunoos/luasec/) + Documentation ------------- Documentation can be automatically generated from the doc/irc.luadoc file, pre-generated documentation can be found in the gh-branch. diff --git a/asyncoperations.lua b/asyncoperations.lua index a9cb87b..2b51224 100644 --- a/asyncoperations.lua +++ b/asyncoperations.lua @@ -29,27 +29,27 @@ end function meta:sendChat(target, msg) -- Split the message into segments if it includes newlines. for line in msg:gmatch("([^\r\n]+)") - self:send("PRIVMSG %s :%s", verify(target, 2), msg) + self:send("PRIVMSG %s :%s", verify(target, 3), msg) end end function meta:sendNotice(target, msg) -- Split the message into segments if it includes newlines. for line in msg:gmatch("([^\r\n]+)") - self:send("NOTICE %s :%s", verify(target, 2), msg) + self:send("NOTICE %s :%s", verify(target, 3), msg) end end function meta:join(channel, key) if key then - self:send("JOIN %s :%s", verify(channel, 2), verify(key, 2)) + self:send("JOIN %s :%s", verify(channel, 3), verify(key, 3)) else - self:send("JOIN %s", verify(channel, 2)) + self:send("JOIN %s", verify(channel, 3)) end end function meta:part(channel) - channel = verify(channel, 2) + channel = verify(channel, 3) self:send("PART %s", channel) if self.track_users then self.channels[channel] = nil @@ -71,7 +71,7 @@ function meta:setMode(t) local add, rem = t.add, t.remove assert(add or rem, "table contains neither 'add' nor 'remove'") - + if add then mode = table.concat{"+", add} end @@ -79,6 +79,6 @@ function meta:setMode(t) if rem then mode = table.concat{mode, "-", rem} end - - self:send("MODE %s %s", verify(target, 2), verify(mode, 2)) + + self:send("MODE %s %s", verify(target, 3), verify(mode, 3)) end diff --git a/init.lua b/init.lua index 5c75a48..bb23ab5 100644 --- a/init.lua +++ b/init.lua @@ -23,13 +23,13 @@ require "irc.asyncoperations" local meta_preconnect = {} function meta_preconnect.__index(o, k) local v = rawget(meta_preconnect, k) - + if not v and meta[k] then error("field '"..k.."' is not accessible before connecting", 2) end return v end - + function new(user) local o = { nick = assert(user.nick, "Field 'nick' is required"); @@ -55,7 +55,7 @@ function meta:unhook(name, id) assert(hooks, "no hooks exist for this event") assert(hooks[id], "hook ID not found") - + hooks[id] = nil end meta_preconnect.unhook = meta.unhook @@ -134,7 +134,7 @@ end function meta:disconnect(message) local message = message or "Bye!" - + self:invoke("OnDisconnect", message, false) self:send("QUIT :%s", message) @@ -200,7 +200,7 @@ handlers["JOIN"] = function(o, prefix, channel) o.channels[channel].users[user.nick] = user end end - + o:invoke("OnJoin", user, channel) end @@ -247,7 +247,7 @@ end handlers["353"] = function(o, prefix, me, chanType, channel, names) if o.track_users then o.channels[channel] = o.channels[channel] or {users = {}, type = chanType} - + local users = o.channels[channel].users for nick in names:gmatch("(%S+)") do local access, name = parseNick(nick) @@ -286,6 +286,18 @@ handlers["KICK"] = function(o, prefix, channel, kicked, reason) o:invoke("OnKick", channel, kicked, parsePrefix(prefix), reason) end +--RPL_UMODEIS +--To answer a query about a client's own mode, RPL_UMODEIS is sent back +handlers["221"] = function(o, prefix, 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) +end + handlers["ERROR"] = function(o, prefix, message) o:invoke("OnDisconnect", message, true) o:shutdown() @@ -311,7 +323,7 @@ function meta:whois(nick) self:send("WHOIS %s", nick) local result = {} - + while true do local line = getline(self, 3) if line then @@ -330,7 +342,6 @@ function meta:whois(nick) if result.account then result.account = result.account[3] - elseif result.registered then result.account = result.registered[2] end diff --git a/util.lua b/util.lua index 5e1698d..91b9ad4 100644 --- a/util.lua +++ b/util.lua @@ -16,7 +16,7 @@ function parse(line) prefix = line:sub(2, space-1) lineStart = space end - + local _, trailToken = line:find("%s+:", lineStart) local lineStop = line:len() local trailing