Closed ghost closed 11 years ago
Here is the code I have for the feature:
bot.on('speak', function(data) { if(data.text.match(/VeggieBot/i)) { bot.speak('Exterminate, Exterminate'); }
if(data.text.match(/VeggieBot/i)) { bot.speak('This room is so cold'); }
if(data.text.match(/VeggieBot/i)) { bot.speak('Always eat your vegetables'); } });
like this?
bot.on('speak', function (data)
{
if (data.text.match(/VeggieBot/i))
{
switch (Math.round(Math.random() * 2))
{
case 0:
bot.speak('Exterminate, Exterminate');
break;
case 1:
bot.speak('This room is so cold');
break;
case 2:
bot.speak('Always eat your vegetables');
break;
}
}
});
ok, thank you. tested out the code and it worked great.
@Turntablelover don't get me wrong. We all love to help a new person out. But personally, I would like to see the person put some effort into either trying themselves, or doing some research. Then when you ask the question, show us what you have tried or where you are confused.
I got the bot to talk when I mention his name but he says all of the phrases at the same time. So I want to know, how to make him say the phrases randomly whenever I mention his name.