Chats-Out number corrected
This commit is contained in:
parent
a8d39d598e
commit
8b733b9365
@ -31,7 +31,6 @@ module.exports = function(RED) {
|
||||
numb = typeof numb ==='number' ? numb : numb.replace(/\D/g, '');
|
||||
const [result] = await (await node.waClient).onWhatsApp(numb)
|
||||
if (result?.exists){
|
||||
console.log(result.exists)
|
||||
return result.jid
|
||||
}
|
||||
return numb = `${numb}@g.us`;
|
||||
@ -74,15 +73,16 @@ module.exports = function(RED) {
|
||||
};
|
||||
|
||||
async function whatsappMultiMediaMessage(numb, whatsappImage, whatsappCaption){
|
||||
whatsappCaption = whatsappCaption || "Image from Node-Red";
|
||||
var whatsappImageBase64 = whatsappImage.split(',')[1] || whatsappImage;
|
||||
try {
|
||||
if (node.waClient.clientType === "waWebClient"){
|
||||
numb = await webNubmerSeteing(numb)
|
||||
var myMessage = new MessageMedia('image/png', whatsappImageBase64, null, null);
|
||||
node.waClient.sendMessage(numb, myMessage, {caption : whatsappCaption || "Image from Node-Red"});
|
||||
node.waClient.sendMessage(numb, myMessage, {caption : whatsappCaption });
|
||||
}
|
||||
else {
|
||||
numb = await socNubmerSeteing(node.number)
|
||||
numb = await socNubmerSeteing(numb)
|
||||
const imageMessage = {
|
||||
text: whatsappCaption,
|
||||
footer: null,
|
||||
@ -111,7 +111,8 @@ module.exports = function(RED) {
|
||||
}
|
||||
|
||||
} else if (message.toNumber){
|
||||
var numbers = message.toNumber instanceof Array ? message.toNumber : Array.of(message.toNumber);
|
||||
let isArr = Object.prototype.toString.call(message.toNumber) == '[object Array]';
|
||||
var numbers = isArr ? message.toNumber : Array.of(message.toNumber);
|
||||
for (number of numbers) {
|
||||
if(message.image){
|
||||
whatsappMultiMediaMessage(number, message.image, message.payload)
|
||||
|
||||
953
package-lock.json
generated
953
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "node-red-contrib-whatsapp-link",
|
||||
"version": "0.1.37-A",
|
||||
"version": "0.1.37",
|
||||
"description": "Node to send and receive whatsapp messages in groups and chats. | No third party APIs",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@ -29,7 +29,7 @@ module.exports = function(RED) {
|
||||
}),
|
||||
puppeteer : {
|
||||
headless : true,
|
||||
args : ['--no-sandbox', '--disable-setuid-sandbox', '--user-data-dir=' + node.id]
|
||||
args : ['--no-sandbox', '--disable-setuid-sandbox', '--user-data-dir=' + WAnode.id]
|
||||
}
|
||||
});
|
||||
|
||||
@ -101,33 +101,6 @@ module.exports = function(RED) {
|
||||
pressenceUpdate(onlineStatus);
|
||||
});
|
||||
|
||||
//Whatsapp-Link Test Features (For Status and Testing Only.)
|
||||
client.on('message_create', async (msg)=> {
|
||||
msg.body = `${msg.body}`;
|
||||
if (msg.body.startsWith('!nodered')){
|
||||
let chat = await msg.getChat();
|
||||
let contact = await msg.getContact();
|
||||
if (chat.isGroup){
|
||||
let msgReply =
|
||||
`Hi From Node-Red.
|
||||
------------------
|
||||
Group Name : ${chat.name},
|
||||
Group Id : ${chat.id.user},
|
||||
Group Admin : ${chat.groupMetadata.owner.user},
|
||||
Participants : ${chat.groupMetadata.size}`
|
||||
msg.reply(msgReply);
|
||||
}
|
||||
else {
|
||||
let msgReply = `Hi @${contact.number} From Node-Red.`
|
||||
chat.sendMessage(msgReply, {
|
||||
mentions : [contact]
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
client.WAConnect = WAConnect;
|
||||
client.WARestart = WARestart;
|
||||
client.WAClose = WAClose;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user