fix chatbot
This commit is contained in:
parent
2ad81f02de
commit
32c756e95f
|
@ -1,18 +1,20 @@
|
|||
import cb from "./lib/cleverbot.mjs";
|
||||
|
||||
export default async bot => {
|
||||
const cleverbot = (await import("./lib/cleverbot.mjs")).default;
|
||||
const cleverbot = await new cb();
|
||||
|
||||
return [{
|
||||
name: "chatbot",
|
||||
call: /^(?![!./[])(.*uw(e|i).*)/i,
|
||||
set: "uwe",
|
||||
active: false,
|
||||
active: true,
|
||||
f: async e => {
|
||||
const res = await cleverbot.ask(e.message
|
||||
.replace(/uw(e|i)/gi, "")
|
||||
.split("?")
|
||||
.join("")
|
||||
.join(" ")
|
||||
);
|
||||
e.reply(res.response);
|
||||
e.reply(res);
|
||||
}
|
||||
}]
|
||||
};
|
||||
|
|
|
@ -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"));
|
||||
});
|
||||
}
|
||||
};
|
||||
};*/
|
||||
|
|
Loading…
Reference in New Issue
Block a user