You don’t do this…
You connect to chat as mybot with the password for mybot which is the oAuth token for mybot
You shouldn’t be using multiple passwords on the same connection.
So you are getting disconnected as you are trying to login as a second/different user on the same connection
So it should be
- connect to chat
- send the username for your bot
- send the password for your bot (which is the oAuth token)
- join channel(s)
When you join you can either do
JOIN #channel
JOIN #channel
JOIN #channel
JOIN #channel
or
JOIN #channel,#channel,#channel,#channel
(Each channel is different naturally), and you can do up to 100 channels in a single join request.
So in this example, you didn’t connect as mybot as the token overrides the username and you are now logged in as the user for token_first_channel
Broadly speaking you are doing it wrong.
TLDR:
A simple workflow:
- My bot is
barrycarlyonbot, which is a “real Twitch User” - I get a token for
barrycarlyonbotwhich includeschat:readand andchat:edit - I connect to chat
- I send the USER as
barrycarlyonbot - I send the PASS of the oAuth token for
barrycarlyonbot - I then JOIN all the channels I need to.
I will have oAuth tokens for streamers, but I don’t use those tokens when connecting to chat, just for reading subscriber data, for example, via the API.
So your chatbot only uses one token on the chat socket itself. And that token represents the user you want to send messages as, which generally will be your chatbot, not a streamer/broadcaster