From d732615d2b261480728e1123f9d0f86dca77d3c9 Mon Sep 17 00:00:00 2001 From: Jeffery Boulanger Date: Thu, 11 Mar 2021 11:53:18 -0800 Subject: [PATCH] Fixed a crash --- .gitignore | 1 + Scripts/twitch/server.lua | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 32d4606..0423356 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,4 @@ luac.out /.vs/twitch2dcs/v15/.suo /.vs/slnx.sqlite +/.vs diff --git a/Scripts/twitch/server.lua b/Scripts/twitch/server.lua index e9bc509..7669cac 100644 --- a/Scripts/twitch/server.lua +++ b/Scripts/twitch/server.lua @@ -75,11 +75,6 @@ function Server:receive() else local prefix, cmd, param = string.match(buffer, "^:([^ ]+) ([^ ]+)(.*)$") - param = string.sub(param,2) - - local param1, param2 = string.match(param,"^([^:]+) :(.*)$") - local user, userhost = string.match(prefix,"^([^!]+)!(.*)$") - if cmd == "376" then self:send("JOIN #"..self.username) end @@ -87,13 +82,18 @@ function Server:receive() local handlers = self.commandHandlers[cmd] if param ~= nil and handlers ~= nil then + param = string.sub(param,2) + + local param1, param2 = string.match(param,"^([^:]+) :(.*)$") + local user, userhost = string.match(prefix,"^([^!]+)!(.*)$") + for i, handler in ipairs(handlers) do handler({ prefix = prefix, user = user, userhost = userhost, - param1 = param1, - param2 = param2 + param1 = param1, + param2 = param2 }) end end