anyone?? :|
proc1 = coroutine.create(function ()
socket = require("socket")
client = socket.tcp()
client:settimeout(0)
res,err = client:connect("192.168.6.14", 6667)
print("connect",res,err)
function send(txt)
...
end
function recv()
...
end
function future()
...
end
-- Identify yourself
send("NICK Luabot")
send("USER Luabot 0 * :I am from the moon")
timer = future()
timer.register(5,function() send("JOIN #bot-tests") end)
repeat
res, err, timeout = recv()
if not err and not timeout then
if string.sub(res,1,4) == "PING" then
-- ping request
send(string.gsub(res,"PING","PONG",1))
elseif string.sub(res,1,1) ~= ":" then
...
end
end
timer.check()
coroutine.yield()
until err
client:close()
end)
function send_to_irc(imsg)
local t = luaLFS:mso(imsg)
local p = luaLFS:stripctrlchars(t.msg)
timer.register(1,function() send("PRIVMSG #bot-tests :"..string.char(3).."2From LFS: "..string.char(3)..p) end)
end
evt_bind(ISP_MSO, send_to_irc)
function tr()
coroutine.resume(proc1)
end
evt_bind(ISP_MCI, tr)
while 1 do
coroutine.resume(proc1)
end