Uwev2/src/inc/trigger/chatbot.mjs
2017-12-05 17:57:46 +01:00

22 lines
459 B
JavaScript

import cleverbot from "./lib/cleverbot";
export default bot => {
bot._trigger.set("chatbot", new bot.trigger({
call: /.*uwe.*/i,
clients: ["tg"],
active: true,
f: e => {
const chat = e.message
.replace(/uwe/gi, "")
.split("?")
.join("");
cleverbot.ask(chat)
.then(res => {
e.reply(res.response);
})
.catch(err => {
console.log(err);
});
}
}));
};