From 516e5e7cda517820aff178f50c1fcd798ced4342 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Tue, 9 May 2017 09:41:38 +1000 Subject: [PATCH] general IRC bridge related fixes to do with #7 --- modules/applications/ircbridge-embedded.lua | 9 +++++---- modules/applications/ircbridge.lua | 7 ++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/modules/applications/ircbridge-embedded.lua b/modules/applications/ircbridge-embedded.lua index f5716a6..e56715a 100644 --- a/modules/applications/ircbridge-embedded.lua +++ b/modules/applications/ircbridge-embedded.lua @@ -3,9 +3,10 @@ function ircb(h,p,n) -- host, port s("IRC bridge connector", function() local ip,h,p = component.proxy(component.list("internet")()),h,p local c=ip.connect(h,p) - local cT = computer.uptime - while computer.uptime() < cT + 2 do + local ct = computer.uptime() + while computer.uptime() < ct+5 do C.yield() + c.finishConnect() end if c.finishConnect() then local ct=computer.uptime() @@ -56,8 +57,8 @@ function ircb(h,p,n) -- host, port s("IRC bridge",function() while true do if ev[1] == "modem_message"then - local pa,pb = ev[6]:match("(.+):(.+)") - if pa and pb then tircb[#tircb+1] = {pa,b64(pb)..","..b64(ev[7])..","..b64(ev[8])..","..b64(ev[9])} end + local pa,pb = ev[7]:match("(.+):(.+)") + if pa and pb then tircb[#tircb+1] = {pa,b64(pb)..","..b64(ev[8])..","..b64(ev[9])..","..b64(ev[10])} end end coroutine.yield() end diff --git a/modules/applications/ircbridge.lua b/modules/applications/ircbridge.lua index 279c147..bd5022e 100644 --- a/modules/applications/ircbridge.lua +++ b/modules/applications/ircbridge.lua @@ -4,8 +4,9 @@ function ircb(h,p,n) -- host, port local ip,h,p = component.proxy(component.list("internet")()),h,p local c=ip.connect(h,p) local ct = computer.uptime() - while computer.uptime() < ct+2 do + while computer.uptime() < ct+5 do C.yield() + c.finishConnect() end if c.finishConnect() then local ct=computer.uptime() @@ -62,8 +63,8 @@ function ircb(h,p,n) -- host, port s("IRC bridge",function() while true do if ev[1] == "modem_message"then - local pa,pb = ev[6]:match("(.+):(.+)") - if pa and pb then tircb[#tircb+1] = {pa,b64(pb)..","..b64(ev[7])..","..b64(ev[8])..","..b64(ev[9])} end + local pa,pb = ev[7]:match("(.+):(.+)") + if pa and pb then tircb[#tircb+1] = {pa,b64(pb)..","..b64(ev[8])..","..b64(ev[9])..","..b64(ev[10])} end end coroutine.yield() end