Closed texjer closed 5 years ago
I don't think so. There will be many commands you can do when you include !
Yes. Replace:
if (message.substring(0, 1) == '!') {
var args = message.substring(1).split(' ');
var cmd = args[0];
args = args.splice(1);
switch(cmd) {
// !ping
case 'ping':
bot.sendMessage({ to: channelID, message: 'Pong!' });
break;
default:
bot.sendMessage({ to: channelID, message: 'Unknown command.' });
}
}
with
var args = message.substring(0).split(' ');
var cmd = args[0];
args = args.splice(1);
switch(cmd) {
// !ping
case 'ping':
bot.sendMessage({ to: channelID, message: 'Pong!' });
break;
default:
bot.sendMessage({ to: channelID, message: 'Unknown command.' });
}
This will cause the bot to attempt to respond to any message (including it's own). As such you will also want to add an if statement checking if the message's userID is the bot's and ignoring it in that case.
If you want it responding to specific commands, edit to include this within the switch case:
case 'newCommand':
bot.sendMessage({ to: channelID, message: 'responce to new command' });
break;
Oh, wow thank you, I'll give this a shot.
I'd like to go prefixless on a simple autoresponder bot. Is this something I can customize the greeterbot to do?