Lua/Love2D/LÖ;VE脚本未接收IRC消息
我一直在尝试使用Love2D连接Twitch聊天室IRC。它管理连接(Lua/Love2D/LÖ;VE脚本未接收IRC消息,lua,irc,twitch,love2d,Lua,Irc,Twitch,Love2d,我一直在尝试使用Love2D连接Twitch聊天室IRC。它管理连接(如果connect==1,则)。我只是不知道如何接收发送给我的任何IRC消息(love.update()) 经过长时间的搜索,我找到了一个解决方案。 而不是这个: connect=irc:connect(“irc.chat.twitch.tv”,6667) 我需要这个: connect=irc:connect(socket.dns.toip(“irc.chat.twitch.tv”),6667)irc:receive()返回什
如果connect==1,则
)。我只是不知道如何接收发送给我的任何IRC消息(love.update()
)
经过长时间的搜索,我找到了一个解决方案。 而不是这个:
connect=irc:connect(“irc.chat.twitch.tv”,6667)
我需要这个:
connect=irc:connect(socket.dns.toip(“irc.chat.twitch.tv”),6667)
irc:receive()返回什么?什么都没有。我一个也没收到。变量“line”和“err”只是nil。它至少应该给出一条错误消息。您是否尝试提供文档中列出的任何模式?我尝试了“*a”
和“*l”
方法。irc:connect()在遇到错误时返回。为该错误提供第二个变量,并查看它是什么。
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