I've been trying to connect to Twitch chat IRC using Love2D. It manages to connect (if connect == 1 then
). I'm just not sure how to receive any IRC messages that are being sent to me (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
I found a solution after spending a long time searching.
Instead of this:
connect = irc:connect("irc.chat.twitch.tv", 6667)
I needed this:
connect = irc:connect(socket.dns.toip("irc.chat.twitch.tv"), 6667)