当我运行我的代码时,它会在控制台中发送垃圾邮件。Module - whatsapp-web.js
码
const { Client } = require('whatsapp-web.js');
const client = new Client();
client.on('qr', (qr) => {
// Generate and scan this code with your phone
console.log('QR RECEIVED', qr);
});
client.on('message', async(msg) => {
const mentions = await msg.getMentions();
for (let contact of mentions) {
console.log(`${contact.pushname} was mentioned`);
}
});
client.initialize();如何用这个模块连接到whatsapp?
控制台
QR received
1@wCO3HYi6B1wat+cAyHe3+tlzfbjiWNxCTP30fEY16YNgmaBuknL/bBDpMNzA2SgfFPfCgQ==,yycd40PiAgEvrk961s+wiBLoMlsFb/eqVpRTN9Ec3FE=,E37yNJ5fmhoX3G/A==类似上述的内容出现在控制台中。
发布于 2021-09-27 13:18:56
应该是这样的
$ npm i qrcode-terminal然后
const qrcode = require('qrcode-terminal');
const { Client } = require('whatsapp-web.js');
const client = new Client();
client.on('qr', qr => {
qrcode.generate(qr, {small: true});
});
client.on('ready', () => {
console.log('Client is ready!');
});
client.initialize();发布于 2022-03-22 10:58:57
按照上面的答案运行代码后,一些qrcode映像将在您的console.next上生成,您可以在whatsapp下面选择‘链接设备’,从三个点缀的右上图标.here中,您应该扫描控制台生成的qrimage .now,它已经准备好发送和接收msg了。
https://stackoverflow.com/questions/68518092
复制相似问题