mukulhase / WebWhatsapp-Wrapper

An API for sending and receiving messages over web.whatsapp [Working as of 18th May 2018]
https://webwhatsapi.readthedocs.io/en/latest/
MIT License
2.02k stars 796 forks source link

Send message to new numbers on WhatsApp Beta #1108

Open vilsonei opened 2 years ago

vilsonei commented 2 years ago

In the new version of WhatsApp Beta when I try to send a message to a new number that is not in the phonebook the method window.Store.Chat.get('xxxx@c.us') always returns undefined.

Has anyone managed to solve it?

vilsonei commented 2 years ago

Solution:

// Create user
var idx = new window.Store.UserConstructor('xxxxx@c.us', {intentionallyUsePrivateConstructor: true});

// Get chat
var chat = window.Store.Chat.find(idx);

// Send message
chat._value.sendMessage('Text');
fabiomello commented 2 years ago

use FindChat

{ id: 'FindChat', conditions: (module) => (module && module.findChat) ? module : null },

dekkardnexus5 commented 2 years ago

Solution:

// Create user
var idx = new window.Store.UserConstructor('xxxxx@c.us', {intentionallyUsePrivateConstructor: true});

// Get chat
var chat = window.Store.Chat.find(idx);

// Send message
chat._value.sendMessage('Text');

HI Vilsonei,

Where should I insert those lines into the code?

duzaq commented 2 years ago

// use this code window.WAPI.sendMessageToID2 = function (id, message, done) { try { // Create user var idx = new window.Store.UserConstructor(id, {intentionallyUsePrivateConstructor: true}); // Get chat var chat = window.Store.Chat.find(idx); // Send message chat._value.sendMessage(message); } catch (e) { return false;

}
if (done !== undefined) done(false);
return false;

}; //window.WAPI.sendMessageToID2 ('0000000000@c.us','oi');