Currently I am creating a bot in python I am a little bit confused on the the syntax of the github page (https://github.com/justintv/Twitch-API/blob/master/IRC.md) in relation to the language. I have the majority of the bot done (it connects and reads messages from chat) but I do not fully understand how this is done. My main focus is how do I read or find the names of the people in stream real time (so NAMES) and when a (new) viewer enters the channel (JOIN). If anyone can please explain these “capabilities,” as they are called in the github page, in terms of python? Thank you!!
To get the JOIN/PART/NAMES, send CAP REQ :twitch.tv/membership\r\n
on the connection before sending your JOIN #channel
s. More on capabilities in the IRCv3 specs.
My code reads:
self.socket = socket.socket()
self.socket.connect((self.host, self.port))
self.socket.send(“PASS {}\r\n”.format(self.passwrd).encode(“utf-8”))
self.socket.send(“NICK {}\r\n”.format(self.nick).encode(“utf-8”))
self.socket.send(“JOIN {}\r\n”.format(self.chan).encode(“utf-8”))
So you are saying add:
self.socket.send(“CAP REQ :twitch.tv/membership\r\n”.format().encode(“utf-8”))
before JOIN? and is there anything more to it?
Thank you for the reply!!
Correct.
Okay I see what its saying now but how do I call the NAME to get he names of the people in the chat, do i do it like:
self.socket.send(“NAMES {}\r\n”.format(self.chan).encode(“utf-8”))?
I think after this I can figure out the rest on my own so thank you very much for the help!
You cannot explicitly request NAMES. The list is sent to you when you first join the channel, after that you need to listen to JOIN/PART to stay up to date.
So if I am understanding you right the server will tell me when a person joins? It seems like that is the case in the example but I want to make sure.
Yes, HOWEVER join/parts are batched up into chunks and delivered every 10/15 seconds or so and additionally, only works for channels/chat rooms under 1000 chatters (or so)
Chunks meaning it will list a lot of names right? and the number of people doesnt really matter for right now since its for me and a friend and we just started streaming.
Yeah sorta.
Everyone 10 seconds (or so) JTV will send all the join/parts together.
So join/parts are not in real time.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.