I’ve decided to create a new Twitch Bot for a friend’s channel, using Node.js, but I am very limited in knowledge. I was just wondering if their was a way for the bot to detect when a user has typed their first message into chat of that stream so the bot could great them? I’m sorry if this is something stupidly simple.
var users = [];
onMessage(user) {
if (users.indexOf(user) < 0) {
bot.sendGreeting();
users.push(user);
}
}
is one solution. (some pseudocode)
But your question is a general programming question, there are evelenty different ways to do this
Thank you for your response, I am very grateful. I tried to use the code but couldn’t get it to work, and I don’t really understand what it all means. If possible, could you explain how it works and to get it working? Thanks.
If user in array don’t send greeting.
If user is not in array add user to array and sendGreeting
It’s up to you how to program this as you’ve asked a general programming question.
This is not a general programming forum.
You’ve provided zero information on what libraries you may be using to access Twitch chat or any sample code to have tried.
My example code won’t work as it’s a general example on how to do something.
I’m not sure what you mean. How do I go about it then if your code isn’t supposed to work?
I gave you a pseudo code answer on how it could work.Not a complete answer.
You didn’t mentioned which library you are using to talk to twitch just “nodeJS”, you asked a general programming question. Not a API question or anything I can “answer” with a complete answer.
You mentioned you are building a bot, so I assume you have already selected a library and are already communicating with Twitch Chat.
What do you mean by a library? As in ‘tmi’?
TMI is Twitch Messaging Interface.
That is the name of Chat itself.
Do you mean tmi.js instead?
Then you have asked a “how do I do x in TMI.js” and that question is better suited to the TMI.js forums/tracker/support sections. Which is not on this forum.
You need to wrap my pseudo code into the message processor function that TMI.js provides. if you are using tmi.js
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.