fix chatbot
This commit is contained in:
@@ -1,7 +1,32 @@
|
||||
import fetch from "flumm-fetch-cookies";
|
||||
import config from "../../../../cfg/config.json";
|
||||
import crypto from "crypto";
|
||||
//import config from "../../../../cfg/config.json";
|
||||
|
||||
export default new class cleverbot {
|
||||
export default class cleverbot {
|
||||
constructor() {
|
||||
return (async () => {
|
||||
await this.init();
|
||||
return this;
|
||||
})();
|
||||
}
|
||||
|
||||
async init() {
|
||||
return await fetch("https://www.cleverbot.com/");
|
||||
}
|
||||
|
||||
async ask(stimulus) {
|
||||
let body = `stimulus=${escape(stimulus)}&cb_settings_scripting=no&islearning=1&icognoid=ws&icognocheck=`;
|
||||
body += crypto.createHash("md5").update(body.substring(7, 33)).digest("hex");
|
||||
|
||||
return decodeURIComponent((await fetch("https://www.cleverbot.com/webservicemin?uc=UseOfficialCleverbotAPI", {
|
||||
method: "POST",
|
||||
body: body
|
||||
})).headers["cboutput"]);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/*export default new class cleverbot {
|
||||
constructor() {
|
||||
this.api = "https://cleverbot.io/1.0";
|
||||
this.nick = "";
|
||||
@@ -40,4 +65,4 @@ export default new class cleverbot {
|
||||
.catch(err => reject("cleverbot is offline or whatever lol"));
|
||||
});
|
||||
}
|
||||
};
|
||||
};*/
|
||||
|
Reference in New Issue
Block a user