Last active
June 6, 2023 06:44
-
-
Save infysumanta/01506ad7ccb8b1f0c90cbdaa9c1462a0 to your computer and use it in GitHub Desktop.
wharsapp-web.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Client } = require("whatsapp-web.js"); | |
const qrcode = require("qrcode-terminal"); | |
const client = new Client(); | |
client.on("qr", (qr) => { | |
qrcode.generate(qr, { small: true }); | |
}); | |
client.on("ready", () => { | |
console.log("Client is ready!"); | |
}); | |
client.on("message", async (message) => { | |
if (message.body === "Hi") { | |
client.sendMessage(message.from, "Hello"); | |
} | |
if (message.body === "Hello") { | |
const chat = await message.getChat(); | |
const contact = await message.getContact(); | |
await chat.sendMessage(`Hello @${contact.id.user}`, { | |
mentions: [contact], | |
}); | |
} | |
}); | |
client.initialize(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment