From 98ccd99f4d1e1cf05ec8863252ed01fc8ee04e33 Mon Sep 17 00:00:00 2001 From: Joshua Simmons Date: Tue, 20 Jul 2010 13:29:33 +1000 Subject: [PATCH 1/5] Fixing On(Channel/User)ModeIs arguments --- init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index ca18f95..f30b82e 100644 --- a/init.lua +++ b/init.lua @@ -288,14 +288,14 @@ 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["ERROR"] = function(o, prefix, message) From 04dbe436f34496a279792b92090fd699229082f3 Mon Sep 17 00:00:00 2001 From: Joshua Simmons Date: Tue, 20 Jul 2010 13:35:25 +1000 Subject: [PATCH 2/5] Adding OnModeChange hook --- doc/irc.luadoc | 1 + init.lua | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/doc/irc.luadoc b/doc/irc.luadoc index 1a98b88..2e42034 100644 --- a/doc/irc.luadoc +++ b/doc/irc.luadoc @@ -139,6 +139,7 @@ function irc:shutdown() --
  • OnKick(channel, nick, kicker, reason)* (kicker is a user table)
  • --
  • OnUserModeIs(modes)
  • --
  • OnChannelModeIs(user, channel, modes)
  • +--
  • OnModeChange(user, target, modes)*
  • -- -- * Event also invoked for yourself. -- † Channel passed only when user tracking is enabled diff --git a/init.lua b/init.lua index f30b82e..1ef238b 100644 --- a/init.lua +++ b/init.lua @@ -298,6 +298,10 @@ handlers["324"] = function(o, prefix, 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) o:invoke("OnDisconnect", message, true) o:shutdown() From d3c6ab849bacc6f8c60e5aebee59d0c418a8225c Mon Sep 17 00:00:00 2001 From: Joshua Simmons Date: Wed, 21 Jul 2010 01:11:29 +1000 Subject: [PATCH 3/5] Fixing wrong method call --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 1ef238b..f2e2390 100644 --- a/init.lua +++ b/init.lua @@ -155,7 +155,7 @@ local function getline(self, errlevel) if err ~= "timeout" and err ~= "wantread" then self:invoke("OnDisconnect", err, true) - self:close() + self:shutdown() error(err, errlevel) end end From ca767c8b42144046b85590bbfbc9d40aab64b2b5 Mon Sep 17 00:00:00 2001 From: Joshua Simmons Date: Wed, 21 Jul 2010 01:12:31 +1000 Subject: [PATCH 4/5] Cleaning up getline function --- init.lua | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/init.lua b/init.lua index f2e2390..1187316 100644 --- a/init.lua +++ b/init.lua @@ -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:shutdown() error(err, errlevel) end + + return line end function meta:think() From d6b4872384936f263e41fa03122e818fb23ee50b Mon Sep 17 00:00:00 2001 From: Joshua Simmons Date: Wed, 21 Jul 2010 01:13:20 +1000 Subject: [PATCH 5/5] According to RFC, NICK should be sent before USER (yes this is a real issue) --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 1187316..5c6ce73 100644 --- a/init.lua +++ b/init.lua @@ -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 = {}