open-wa / wa-automate-nodejs

💬 🤖 The most reliable tool for chatbots with advanced features. Be sure to 🌟 this repository for updates!
https://docs.openwa.dev/
Other
3.13k stars 599 forks source link

npm #2551

Closed DaruinHerrera closed 2 years ago

DaruinHerrera commented 2 years ago

Are you using the latest version of the library?

What type of session are you experiencing this issue on?

Legacy (Normal)

What type of host account are you experiencing this issue on?

Personal account (normal)

Mode

My own code

Current Behavior

When I try to use the multisession from an api, I manage to scan the first one and create the first session for a device, when I try to connect the second device the console stays in Launch inject: 150ms

Expected Behavior

I expected another qr to be generated to link another whatsapp line

Steps To Reproduce

  1. function qrs(req, res) {

    const { sessionId } = req.body;

    const clientSessionRegistry = {};

    async function start(client){ //save for later clientSessionRegistry[client.getSessionId()] = client;
    }

    create({sessionId:sessionId}).then(client => start(client));

    ev.on('qr.**', async (qrcode,sessionId) => { //base64 encoded qr code image const imageBuffer = Buffer.from(qrcode.replace('data:image/png;base64,',''), 'base64'); fs.writeFileSync(qr_code${sessionId?'_'+sessionId:''}.png, imageBuffer); });

    return res.status(200).send({ message:'conectado' });

}

create() code

function qrs(req, res)
{

  const { sessionId } = req.body; 

  const clientSessionRegistry = {};

  async function start(client){
    //save for later
    clientSessionRegistry[client.getSessionId()] = client;    
  }

  create({sessionId:sessionId}).then(client => start(client));

  ev.on('qr.**', async (qrcode,sessionId) => {
    //base64 encoded qr code image
    const imageBuffer = Buffer.from(qrcode.replace('data:image/png;base64,',''), 'base64');
    fs.writeFileSync(`qr_code${sessionId?'_'+sessionId:''}.png`, imageBuffer);
  });

  return res.status(200).send({ message:'conectado' });

  /*client.onMessage(async message => {
      if (message.body === 'Hi') {
        await client.sendText(message.from, '👋 Hello!');
      }
    });*/
}

DEBUG INFO

{
  "WA_VERSION": "2.2206.9",
  "WA_AUTOMATE_VERSION": "4.31.8 UPDATE AVAILABLE: 4.31.13",
  "BROWSER_VERSION": "HeadlessChrome/99.0.4844.0",
  "START_TS": 1646681847146,
  "LATEST_VERSION": false,
  "CLI": false
}

Environment

- OS: Windows 10
- Node: 16.14.0
- npm: 8.3.1

Screenshots/Logs

`function qrs(req, res) {

const { sessionId } = req.body;

const clientSessionRegistry = {};

async function start(client){ //save for later clientSessionRegistry[client.getSessionId()] = client;
}

create({sessionId:sessionId}).then(client => start(client));

ev.on('qr.**', async (qrcode,sessionId) => { //base64 encoded qr code image const imageBuffer = Buffer.from(qrcode.replace('data:image/png;base64,',''), 'base64'); fs.writeFileSync(qr_code${sessionId?'_'+sessionId:''}.png, imageBuffer); });

return res.status(200).send({ message:'conectado' });

/client.onMessage(async message => { if (message.body === 'Hi') { await client.sendText(message.from, '👋 Hello!'); } });/ }`

Anything else?

https://ibb.co/N1WYYx4

smashah commented 2 years ago

Update to the latest version

DaruinHerrera commented 2 years ago

✓ Version: 4.31.8 undefined ✓ No session data file found for session : session ✓ Page loaded ┌─────────────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ (index) │ Values │ ├─────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ WA_VERSION │ '2.2206.9' │ │ PAGE_UA │ 'WhatsApp/2.2147.16 Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36' │ │ WA_AUTOMATE_VERSION │ '4.31.8 UPDATE AVAILABLE: 4.31.13' │ │ BROWSER_VERSION │ 'HeadlessChrome/99.0.4844.0' │ │ OS │ 'Windows 10' │ │ START_TS │ 1646691147722 │

DaruinHerrera commented 2 years ago

https://ibb.co/R2xNfRn

smashah commented 2 years ago

The latest version is 4.31.13, you are using 4.31.8

smashah commented 2 years ago

to update:

> npm i @open-wa/wa-automate@latest

If it still doesn't work after updating please let me know