Lua / Love2D / LÖVE 脚本无法收到 IRC 消息

我一直在尝试使用 Love2D 连接到 Twitch 聊天 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() --> 无返回值
    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
end
点赞
用户7572104
用户7572104

我花了很长时间搜索后找到了一个解决方案。

不再使用:

connect = irc:connect("irc.chat.twitch.tv", 6667)

而是需要使用:

connect = irc:connect(socket.dns.toip("irc.chat.twitch.tv"), 6667)
2018-03-24 15:40:26