-
Notifications
You must be signed in to change notification settings - Fork 76
/
index.js
35 lines (30 loc) · 924 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const qrcode = require("qrcode-terminal");
const request = require("request");
const { Client, LocalAuth, MessageMedia } = require("whatsapp-web.js");
const { ChatCompletion } = require('./churchless.js');
const client = new Client({
puppeteer: {
executablePath: '/usr/bin/google-chrome-stable', //change if you are using windows or Mac OS (See puppeteer docs for more info)
headless: true
},
authStrategy: new LocalAuth()
});
client.initialize();
client.on("qr", (qr) => {
qrcode.generate(qr, { small: true });
});
client.on("authenticated", () => {
console.log("Auth Completed!");
});
client.on("ready", () => {
console.log("Bot is ready!");
});
client.on("message", async (message) => {
if(message.type == "chat"){
const chatBotMessage = await ChatCompletion.create(question);
await message.reply(chatBotMessage);
}
else{
message.reply("I only reply to text messages");
}
});