//contains is used for checking if a specific term is anywhere in a string. Useful when you don't have a command that
//requires parameters, such as !help
function contains(string, terms){
for(var i=0; i<terms.length; i++){
if(string.toLowerCase().indexOf(terms[i].toLowerCase()) == -1){
return false;
}
}
return true;
}
//example:
if(contains(data.message, ["!help"]){
//do something there
}
/*stripHTML (I haven't really used this, so not sure if it will work; found on github) is used to remove the html tags
that are sent to the client to show the color (code source: https://github.com/whiskers75/whiskdicebot/blob/master/bot.js)*/
function stripHTML(html) {
return html.replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>?/gi, '');
}
//example:
if(stripHTML(data.message).split(" ")[0] == "!tip"){//if the first 'word' of the command without the html is '!tip'
//do stuff here
}
}