forked from try-catch-dev/BotWhatsapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
45 lines (29 loc) · 840 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
36
37
38
39
40
41
42
const qrcode = require('qrcode-terminal');
const { Client, LocalAuth } = require('whatsapp-web.js');
const { EditPhotoHandler } = require('./feature/edit_foto');
const { ChatAIHandler } = require('./feature/chat_ai');
const client = new Client({
authStrategy: new LocalAuth()
});
client.on('qr', qr => {
qrcode.generate(qr, { small: true });
});
client.on('ready', () => {
console.log('Client is ready!');
});
client.on('message', async msg => {
const text = msg.body.toLowerCase() || '';
//check status
if (text === '!ping') {
msg.reply('pong');
}
// #edit_bg/bg_color
if (text.includes("#edit_bg/")) {
await EditPhotoHandler(text, msg);
}
// #ask/question?
if (text.includes("#ask/")) {
await ChatAIHandler(text, msg);
}
});
client.initialize();