I'm programming a bot to monitor chat on twitch.tv over IRC. Here's what a successful connection and login looks like in Telnet:
Microsoft Telnet> o irc.twitch.tv 6667
PASS <password>
NICK <username>
:tmi.twitch.tv 001 <user> :Welcome, GLHF!
:tmi.twitch.tv 002 <user> :Your host is tmi.twitch.tv
:tmi.twitch.tv 003 <user> :This server is rather new
:tmi.twitch.tv 004 <user> :-
:tmi.twitch.tv 375 <user> :-
:tmi.twitch.tv 372 <user> :You are in a maze of twisty passages, all alike.
:tmi.twitch.tv 376 <user> :>
I wrote a simple test script that successfully connects to the server but only receives part of the message.
# irctest.py
import socket
HOST='irc.twitch.tv'
PORT=6667
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
s.sendall(b"PASS oauth:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\r\n")
s.sendall(b"NICK user\r\n")
data = s.recv(2048)
s.close()
print(repr(data.decode()))
The string printed with data.decode()
is only the first line of the successful connection response:
':tmi.twitch.tv 001 <user> :Welcome, GLHF!\r\n'
This means that the connection works as intended. I've tried doing a second s.recv(2048)
but this hangs indefinitely with s.settimeout(None)
. I've also tried increasing the buffer size but this doesn't appear to have any effect. Anyone know what's going on?
Twitch has a help doc on IRC connections here.