Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

104
Views
Make twitchbot check if I said X before saying Y

I'm new to js and try setting up a twitch bot. All works fine for basic commands and connexion to chat. But I would like to have the bot check if a user already said salut|bonjour|hey|bonsoir before saying banane. If false, the bot would tell him Hey, tu dis pas bonjour toi?!! , if true she'd say on m'a appelée?

With this pc of code I wrote, even if I already said one of salut|bonjour|hey|bonsoir, bot only says Hey, tu dis pas bonjour toi?!! and doesn't go to on m'a appelée?

What am I missing? Thanks

var usersayhello = {};

client.on('message', (channel, user, message, self) => {
if(self) return;
message=message.toLowerCase();
message=' '+message+' ';

if(/[ ]+anita[ \?]+/.test(message)){
    
    if(/(salut|bonjour|hey|bonsoir)([ ]+)anita/.test(message)){
        usersayhello = true; 
        if(user.username == 'blablabla123'){
            var responsebonjour = [
                `Salut @${user.username}! Planquez-vous! Ca va encore troller sec`
        `Hey @${user.username}, tu voles aujourd'hui?`
            ];
        }
        else{
            var responsebonjour = [
                `Salut @${user.username}, je suis contente de te voir, tu vas bien?`,
                `Hey @${user.username}, t'es venu pour moi j'espère`,
                `Hello @${user.username}, comment vas-tu?`,
                `Tu ne peux vraiment pas te passer de moi, toi! ^^`
            ];
        }

client.say(channel,responsebonjour[Math.floor(Math.random()*responsebonjour.length)]);
}

if(message == ` banane ` && checkifusersayhello (channel,user,usersayhello)) {
    client.say(channel, `on m'a appelée?`);
}  

function checkifusersayhello(channel,user,usersayhello) {
    if (!usersayhello[user.username]){
    client.say(channel, `Hey, tu dis pas bonjour toi?!!`);
    return false;
    }
    return true;
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!