Replaced regex expression with tokens due to yo-lkajdfasad hello-adkflajfd and other random garbage being accepted

This commit is contained in:
Brandon Rozek 2016-08-14 20:20:35 -04:00
parent 0795d27b67
commit 41628e583e

View file

@ -1,6 +1,5 @@
var Command = require('./Command.js');
var grabTokens = require('../helpers/grabTokens.js');
var greetings = "hello|hi|hey|yo|morning|afternoon|evening";
var happy = "yay|woo|yess|:D|:\\)"
var url = "link|url";
@ -15,7 +14,7 @@ var condition = function(text, userData) {
(new RegExp(happy, 'i').test(text)) ||
((tokens.contain("who") || tokens.contain("what")) && tokens.contain("brandon") && tokens.contain('rozek')) ||
((tokens.contain("how") || tokens.contain("doing") || tokens.contain("up")) && tokens.contain("brandon")) ||
((tokens.superContain('rozbot') || privateMessage) && new RegExp(greetings, 'i').test(text)) ||
((tokens.superContain('rozbot') || privateMessage) && (tokens.contain("hello") || tokens.contain("hi") || tokens.contain("hey") || tokens.contain("yo") || tokens.contain("morning") || tokens.contain("afternoon") || tokens.contain("evening"))) ||
((tokens.superContain("rozbot") || privateMessage) && tokens.superContain("what") && (tokens.contain("up") || tokens.contain("doing"))) ||
(tokens.superContain("rozbot") && tokens.superContain("what") && tokens.contain("job"))
}
@ -83,7 +82,7 @@ module.exports = new Command("NaturalSpeech", condition, function(text, send, us
/*
Good morning Rozbot! -> Hello [user]!
*/
else if ((tokens.superContain('rozbot') || privateMessage) && new RegExp(greetings, 'i').test(text)) {
else if ((tokens.superContain('rozbot') || privateMessage) && (tokens.contain("hello") || tokens.contain("hi") || tokens.contain("hey") || tokens.contain("yo") || tokens.contain("morning") || tokens.contain("afternoon") || tokens.contain("evening"))) {
send("Hello " + from + "!");
}
/*