chatbot bugfix

This commit is contained in:
Flummi 2017-12-05 19:57:23 +01:00
parent a0b991de89
commit b9d997b652

View File

@ -12,13 +12,19 @@ class cleverbot {
const options = { const options = {
url: `${this.api}/create`, url: `${this.api}/create`,
method: "POST", method: "POST",
body: cfg.main.chatbot.val, body: Object.assign(cfg.main.chatbot.val, {
nick: "uwibot"
}),
json: true json: true
}; };
rp(options) rp(options)
.then(res => { .then(res => {
if(res.status === "success") if(res.status === "success")
this.nick = res.nick; this.nick = res.nick;
else {
this.nick = "uwibot";
console.log(res.status);
}
}) })
.catch(err => console.log(err)); .catch(err => console.log(err));
} }
@ -35,15 +41,8 @@ class cleverbot {
json: true json: true
}; };
rp(options) rp(options)
.then(res => { .then(res => res.status === "success"?resolve(res):reject(res.status))
if(res.status === "success") .catch(err => reject(err));
resolve(res);
else
reject(res.status);
})
.catch(err => {
reject(err);
});
}); });
} }
}; };