PetterKraabol / Twitch-Python

Object-oriented Twitch API for Python developers
https://pypi.org/project/twitch-python
MIT License
214 stars 37 forks source link

is possible to access more than 1 channel at time? #19

Closed ENDERZOMBI102 closed 4 years ago

ENDERZOMBI102 commented 4 years ago

the title says all, but there's more infos. i want to build a bot cabable of running on multiple channels at the same time, i thinked of a way to do that but i first want to know if this lib is capable of handling multiple channels already

emwjacobson commented 4 years ago

It's been a while since you asked, but I figure I might as well put in my 2 cents from playing with this library for a couple of days.

To answer your question of is it capable, yes, its technically capable. The problem is that is isn't implemented.

https://github.com/PetterKraabol/Twitch-Python/blob/60b52bd8ce35136bb0c3e640616726077ca7c15a/twitch/chat/chat.py#L32-L34 By adding another self.irc.join_channel("channel_name") you can connect to another channel and receive messaged from it.

https://github.com/PetterKraabol/Twitch-Python/blob/60b52bd8ce35136bb0c3e640616726077ca7c15a/twitch/chat/chat.py#L41-L42 The other problem is where it uses self.channel to tell which channel the message is coming from. self.channel is set when you first create the Chat object and is set to whichever channel that you set when you first created it. This means that if you want it to identify which channel it comes from, you need to do some more parsing of the PRIVMSG message itself to determine the channel. Technically shouldn't be too hard.

EDIT: Something else I would recommend though is possible just using multiple Chat objects in order to connect to multiple channels.

ENDERZOMBI102 commented 4 years ago

i've "fixed" this problem with my own code, so i'm closing this