Lua / Love2D / LÖVE 脚本不接收 IRC 消息
Lua / Love2D / LÖVE script not receiving IRC messages
我一直在尝试使用 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
找了半天终于找到解决办法了。
而不是这个:
connect = irc:connect("irc.chat.twitch.tv", 6667)
我需要这个:
connect = irc:connect(socket.dns.toip("irc.chat.twitch.tv"), 6667)
我一直在尝试使用 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
找了半天终于找到解决办法了。
而不是这个:
connect = irc:connect("irc.chat.twitch.tv", 6667)
我需要这个:
connect = irc:connect(socket.dns.toip("irc.chat.twitch.tv"), 6667)