let level = 0;
let usersName;
let path;
const getBotReply = (msg) => {
if (level === 0) {
level = 1;
usersName = msg;
return "Chur " + usersName + ". Do you live in Raglan?";
}
if (level === 1) {
level = 2;
if (msg === "yes") {
path = "left-yes";
return "Do you know how to surf?";
}
if (msg === "no") {
path = "right-no";
return "Are you from Auckland?";
}
}
基本上我想要它,而不是输入是或否。用户将键入重置,它将返回到“级别 0”
我试过了:
if (msg === "reset") {
level = 0;
}