I’m creating a chat bot with Twitch API following this docs.
I created two twitch account, one for a main channel and the other is for a bot. I registered my app using the account for the bot.
The chatbot connection works and the chatbot sends a message to a desired channel. However, the message is always sent from an account which I am logged in.
So if I’m logged into the main channel account, the chat message is sent by that account, and the other way round for when I’m logged in with the bot account.
Could someone help me figure out how to solve this?
"CAP REQ :twitch.tv/tags twitch.tv/commands twitch.tv/membership"
socket.send("PRIVMSG #main_channel :HeyGuys <3 Hello world");
The bot will send a message using the name of the user that the
access_token belongs to.
It’s doint exactly what it’s supposed to, you auth with account (a) and set your script to use account (a)'s token then it will use that token.
So why are you (re)authing as your actual account?
Thank you for the reply!
It might sound dumb to ask this, but could you enlighten me how to have a differnt name for a chatbot?
I’m not familiar with how twitch works either
You’ve already figured it out.
You gave your script a bot account token. You just need to leave your script using that token and not give it your broadcaster account token
Does that mean two browser needs to be open, one for the main account and the other for the chatbot account, and use chatbot accont to give my script an account token?
if your script requires a bot token to talk as, and a broadcaster token to run broadcaster operations
Then you’ll need a way to provide both those tokens to your script.
People often will authenticate their broadcaster account to a script on a main browser, and then do the bot via incognito mode.
But sure you can do it via two browsers, you just need to copy the resultant tokens into your script as needed
I store my tokens in a database/redis/something so my script will fetch from there.
Ahh I see!! Thank you so much for your help.
I’m using websocket, but I’m wondering if the behaviour (ie. using both main browser and incognito mode) is the same when using tmi.js.
Whatever library you use will use whatever token you feed it.
So if you feed it the wrong token in the wrong place then yeah it’ll use the wrong token
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.