123456789101112131415161718192021222324252627282930313233343536 |
- mooni2p = require("mooni2p")
- local session_sock = assert(mooni2p.create_session("irctest", "TRANSIENT"))
- local sock = assert(mooni2p.stream_connect("irctest", "irc.ilita.i2p"))
- sock:send("NICK luabot\n")
- sock:send("USER luabot luabot luabot :luabot\n")
- while 1 do
- data = sock:receive("*l")
- if #data == 0 then
- print("connection closed")
- break
- else
- print(pdata)
- if data:sub(1, 6) == "PING :" then
- pdata = data:sub(7, -1)
- sock:send("PONG :" .. pdata .. "\n")
- else
- if data:sub(1,1) == ":" then
- local words = mooni2p._split(data)
- if words[2] == "422" or words[2] == "376" then
- sock:send("JOIN #ru\n")
- end
- end
- end
- if string.find(data, "STOP BOT") then
- break
- end
- end
- end
- sock:close()
- session_sock:close()
|