-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
33 lines (28 loc) · 958 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
import qrcode from 'qrcode-terminal'
import pkg from 'whatsapp-web.js';
import {handleMsg} from './settings/handler.js'
import { range } from './config/config.js';
const {Client,LocalAuth,MessageMedia} =pkg;
const client = new Client({
authStrategy: new LocalAuth({dataPath:"./auth_data"}), // ./auth_data is the path where session data is stored for session restoration
puppeteer:{headless:true,
args:['--no-sandbox']}
});
client.on('qr', (qr) => {
qrcode.generate(qr, {small: true});
});
client.on('ready', () => {
console.log('Client is ready!');
});
client.on('message',async (message)=>{
console.log("meaasage is ",message,"\n");
const chat = await message.getChat();
console.log("chat is ",chat,"\n");
if(message.body==='$addthischat'){
range.push(chat.id._serialized)
}
if((range.find(elm=>elm===chat.id._serialized))!==undefined){
handleMsg(message,chat);
}
})
client.initialize();