我一直在尝试用Love2D连接到Twitch chat IRC。它设法连接(if connect == 1 then)。我只是不确定如何接收任何发送给我的IRC消息(love.update())。
function love.load()
oauth = "oauth:someoauthhere"
user = "botname"
channel = "channeltojoin"
love.graphics.setFont(love.graphics.newFont(32))
socket = require("socket")
irc = socket.tcp()
connect = irc:connect("irc.chat.twitch.tv", 6667)
if connect == 1 then -- MAKES IT PAST THIS
irc_messages = {}
irc:send("PASS " .. oauth)
irc:send("USER " .. user)
irc:send("JOIN #" .. channel)
end
end
function update(dt)
line, err = irc:receive() --> Returns nothing
if line then
table.insert(irc_messages, line)
end
end
function love.draw()
if not next(irc_messages) == nil then
love.graphics.printf(table.concat(irc_messages, "\n"), 0, 0)
end
endhttps://stackoverflow.com/questions/49439769
复制相似问题