-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
41 lines (33 loc) · 1.16 KB
/
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
const qrcode = require("qrcode-terminal");
const { Client, LocalAuth } = require("whatsapp-web.js");
const client = new Client({
puppeteer: {
args: ['--no-sandbox', "--disable-setuid-sandbox"]
},
});
client.on("qr", (qr) => {
qrcode.generate(qr, { small: true});
});
client.on("ready", async () => {
console.log("Client is ready!");
});
client.on("message", async (msg) => {
const chat = await msg.getChat();
const contact = await msg.getContact();
await chat.sendMessage(`Hello @${contact.id.user} Thanks for messaging, Please checkout https://anshusharma.me
${await contact.getProfilePicUrl() && ` Here is your Profile Link ${await contact.getProfilePicUrl()}`} ${await contact.getAbout() && `and your bio is ${await contact.getAbout()}`}`, {
mentions: [contact],
});
});
client.on("call", async (call) => {
try {
console.log(call.from);
await call.reject();
const contact = await client.getContactById(call.from);
const msg = await contact.getChat()
await msg.sendMessage("Please call on 9518008087")
} catch (error) {
console.log(error);
}
});
client.initialize();