general IRC bridge related fixes to do with #7

This commit is contained in:
Izaya 2017-05-09 09:41:38 +10:00
parent 35d0ee1d0d
commit 516e5e7cda
2 changed files with 9 additions and 7 deletions

View File

@ -3,9 +3,10 @@ function ircb(h,p,n) -- host, port
s("IRC bridge connector", function() s("IRC bridge connector", function()
local ip,h,p = component.proxy(component.list("internet")()),h,p local ip,h,p = component.proxy(component.list("internet")()),h,p
local c=ip.connect(h,p) local c=ip.connect(h,p)
local cT = computer.uptime local ct = computer.uptime()
while computer.uptime() < cT + 2 do while computer.uptime() < ct+5 do
C.yield() C.yield()
c.finishConnect()
end end
if c.finishConnect() then if c.finishConnect() then
local ct=computer.uptime() local ct=computer.uptime()
@ -56,8 +57,8 @@ function ircb(h,p,n) -- host, port
s("IRC bridge",function() s("IRC bridge",function()
while true do while true do
if ev[1] == "modem_message"then if ev[1] == "modem_message"then
local pa,pb = ev[6]:match("(.+):(.+)") local pa,pb = ev[7]:match("(.+):(.+)")
if pa and pb then tircb[#tircb+1] = {pa,b64(pb)..","..b64(ev[7])..","..b64(ev[8])..","..b64(ev[9])} end if pa and pb then tircb[#tircb+1] = {pa,b64(pb)..","..b64(ev[8])..","..b64(ev[9])..","..b64(ev[10])} end
end end
coroutine.yield() coroutine.yield()
end end

View File

@ -4,8 +4,9 @@ function ircb(h,p,n) -- host, port
local ip,h,p = component.proxy(component.list("internet")()),h,p local ip,h,p = component.proxy(component.list("internet")()),h,p
local c=ip.connect(h,p) local c=ip.connect(h,p)
local ct = computer.uptime() local ct = computer.uptime()
while computer.uptime() < ct+2 do while computer.uptime() < ct+5 do
C.yield() C.yield()
c.finishConnect()
end end
if c.finishConnect() then if c.finishConnect() then
local ct=computer.uptime() local ct=computer.uptime()
@ -62,8 +63,8 @@ function ircb(h,p,n) -- host, port
s("IRC bridge",function() s("IRC bridge",function()
while true do while true do
if ev[1] == "modem_message"then if ev[1] == "modem_message"then
local pa,pb = ev[6]:match("(.+):(.+)") local pa,pb = ev[7]:match("(.+):(.+)")
if pa and pb then tircb[#tircb+1] = {pa,b64(pb)..","..b64(ev[7])..","..b64(ev[8])..","..b64(ev[9])} end if pa and pb then tircb[#tircb+1] = {pa,b64(pb)..","..b64(ev[8])..","..b64(ev[9])..","..b64(ev[10])} end
end end
coroutine.yield() coroutine.yield()
end end