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()
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

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 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