chatbot (wip)

This commit is contained in:
Flummi 2017-12-04 20:39:30 +01:00
parent d209b2b54e
commit f371123c95
2 changed files with 51 additions and 1 deletions

View File

@ -0,0 +1,49 @@
import rp from "request-promise";
import jsdom from "jsdom";
let botcust2 = "";
export default bot => {
bot._trigger.set("chatbot", new bot.trigger({
call: /.*uwe.*/i,
active: false,
f: e => {
const chat = e.message;
mitsuku(chat)
.then(res => {
e.reply(res);
})
.catch(err => {
console.log(err);
});
}
}));
};
function mitsuku(msg) {
return new Promise((resolve, reject) => {
const options = {
uri: "https://kakko.pandorabots.com/pandora/talk?botid=87437a824e345a0d&skin=chat",
method: "POST",
body: {
botcust2: botcust2,
message: msg
},
headers: {
Cookie: `botcust2=${botcust2}`
},
json: true
};
rp(options)
.then(res => resolve(res))
.catch(err => reject(err));
});
}
(function init() {
rp("https://kakko.pandorabots.com/pandora/talk?botid=87437a824e345a0d&skin=chat")
.then(res => {
const dom = new jsdom.JSDOM(res);
botcust2 = dom.window.document.querySelector("input[name=botcust2]").value;
});
})();

View File

@ -1,4 +1,5 @@
import cfg from "./cfg";
import chatbot from "./chatbot";
import coins from "./coins";
import cookie from "./cookie";
import core from "./core";
@ -17,7 +18,7 @@ import uwe from "./useless_uwe";
import wttr from "./wttr";
export default [
cfg, coins, cookie, core, debug,
cfg, chatbot, coins, cookie, core, debug,
drugs, help, kernel, mcmaniac,
parser, quotes, rape, sandbox,
urban, nxy, uwe, wttr