-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
37 lines (30 loc) · 841 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
const { Client, LocalAuth } = require("whatsapp-web.js");
const qrcode = require('qrcode-terminal');
const client = new Client({
puppeteer: {
headless: true,
args: ["--no-sandbox", "--disable-setuid-sandbox"],
},
authStrategy: new LocalAuth(),
});
client.on("qr", (qr) => {
qrcode.generate(qr, { small: true });
});
client.on("authenticated", (session) => {
console.log("AUTHENTICATED", session);
});
client.on("auth_failure", (msg) => {
console.error("AUTHENTICATION FAILURE", msg);
});
client.on("ready", () => {
console.log("READY");
});
client.on("message", async (msg) => {
if (msg.from.endsWith('@g.us')) { // grup
return;
}
if (msg.body.startsWith("!ping")) {
msg.reply("pong");
}
});
client.initialize();