【问题标题】:Lua / Love2D / LÖVE script not receiving IRC messagesLua / Love2D / LÖVE 脚本没有收到 IRC 消息
【发布时间】:2018-05-31 19:18:29
【问题描述】:

我一直在尝试使用 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() --> 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
end

【问题讨论】:

标签: lua irc twitch love2d


【解决方案1】:

经过长时间的搜索,我找到了解决方案。 而不是这个:
connect = irc:connect("irc.chat.twitch.tv", 6667)
我需要这个:
connect = irc:connect(socket.dns.toip("irc.chat.twitch.tv"), 6667)

【讨论】:

    猜你喜欢
    • 2016-03-23
    • 2020-07-19
    • 1970-01-01
    • 2011-09-07
    • 2017-10-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-23
    相关资源
    最近更新 更多