Baileys icon indicating copy to clipboard operation
Baileys copied to clipboard

[BUG] Nine Digit in Brazil

Open JoaoNetoDev opened this issue 1 year ago • 3 comments

In Brazil, there was an update a few years ago that added a ninth digit, adding a 9 to the left on mobile numbers...

I'm facing a problem where onwhatsapp returns true both with and without 9... Some require it not to have it and others yes...

My number, for example, if I send a message with 9, it generates a chat with a ghost account (non-existent)... and the message doesn't get anywhere... Other accounts only receive if you send with 9.

Help-me!

JoaoNetoDev avatar Aug 06 '22 17:08 JoaoNetoDev

In Brazil, there was an update a few years ago that added a ninth digit, adding a 9 to the left on mobile numbers...

I'm facing a problem where onwhatsapp returns true both with and without 9... Some require it not to have it and others yes...

My number, for example, if I send a message with 9, it generates a chat with a ghost account (non-existent)... and the message doesn't get anywhere... Other accounts only receive if you send with 9.

Help-me!

@JoaoNetoDev you can get the result onWhatsApp method and read the jid field that already returns corrected, I suggest replacing the jid by the one returned in this method, here it works for me.

rafaeldalbosco avatar Aug 07 '22 11:08 rafaeldalbosco

My number only receives if I send it with 8 digits, but this function returns the incorrect ID, see the example below of the return it gave me:

{ "error": false, "date": true, "idWpp": "[email protected]" }

JoaoNetoDev avatar Aug 07 '22 16:08 JoaoNetoDev

In Brazil, there was an update a few years ago that added a ninth digit, adding a 9 to the left on mobile numbers... I'm facing a problem where onwhatsapp returns true both with and without 9... Some require it not to have it and others yes... My number, for example, if I send a message with 9, it generates a chat with a ghost account (non-existent)... and the message doesn't get anywhere... Other accounts only receive if you send with 9. Help-me!

@JoaoNetoDev you can get the result onWhatsApp method and read the jid field that already returns corrected, I suggest replacing the jid by the one returned in this method, here it works for me.

In Brazil, there was an update a few years ago that added a ninth digit, adding a 9 to the left on mobile numbers... I'm facing a problem where onwhatsapp returns true both with and without 9... Some require it not to have it and others yes... My number, for example, if I send a message with 9, it generates a chat with a ghost account (non-existent)... and the message doesn't get anywhere... Other accounts only receive if you send with 9. Help-me!

@JoaoNetoDev you can get the result onWhatsApp method and read the jid field that already returns corrected, I suggest replacing the jid by the one returned in this method, here it works for me.

Tell me more about your test logic... because for me it returns Jid both with the ninth digit and without... false positive!

I'm thinking of testing without the ninth digit and only adding the 9 to the left if it returns false, because I think that those that are mandatory to add the nine give an error if you test with only 8 digits

JoaoNetoDev avatar Aug 08 '22 13:08 JoaoNetoDev

fix DDD in Brasil

const jid = req.body.jid; const numberDDI = jid.substr(0, 2); const numberDDD = jid.substr(2, 2); const numberUser = jid.substr(-8, 8); const message = req.body.message;

if (numberDDI !== '55') { SendMessage(jid, { text: message }) .then(response => { res.status(200).json({ status: true, response: response }); }) .catch(err => { res.status(500).json({ status: false, response: err }); }); }

if (numberDDI === '55' && numberDDD <= 30) { const number = "55" + numberDDD + "9" + numberUser + "@s.whatsapp.net"; SendMessage(number, { text: message }) .then(response => { res.status(200).json({ status: true, response: response }); }) .catch(err => { res.status(500).json({ status: false, response: err }); }); }

if (numberDDI === '55' && numberDDD > 30) { const number = "55" + numberDDD + numberUser + "@s.whatsapp.net"; SendMessage(number, { text: message }) .then(response => { res.status(200).json({ status: true, response: response }); }) .catch(err => { res.status(500).json({ status: false, response: err }); }); }

adrianokelvio avatar Aug 09 '22 02:08 adrianokelvio

inside the isExists function it already returns the correct jid, so just take the result of it and replace

lopesclayton avatar Aug 09 '22 12:08 lopesclayton

inside the isExists function it already returns the correct jid, so just take the result of it and replace

I use it just as @lopesclayton reported and it works for me.

No problem at Baileys, I see you have some solutions for your reported issue. I believe you can close the issue @JoaoNetoDev

rafaeldalbosco avatar Aug 09 '22 12:08 rafaeldalbosco

I'll test your suggestions...thanks a lot for the clarification!

JoaoNetoDev avatar Aug 09 '22 12:08 JoaoNetoDev