7 Commits

Author SHA1 Message Date
b04edfd913 ncy 3 2025-11-17 14:47:10 +01:00
6daa3aa443 consistency 2 2025-11-17 14:44:16 +01:00
a7542f9272 consistency fixes 2025-11-17 14:42:57 +01:00
a8b9330e06 bump 2025-11-17 14:33:19 +01:00
b1db84a674 npm error fixes / updated packages. 2025-11-17 14:33:01 +01:00
e5238598c0 version 2025-11-17 14:30:07 +01:00
f8f2fce606 Fixed validation 2025-11-17 14:23:50 +01:00
3 changed files with 63 additions and 14 deletions

View File

@@ -20,13 +20,30 @@ module.exports = function(RED) {
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
async function whatsappMessage(numb , inputMessage){
// Validate message
if (!inputMessage) {
node.error('Error Sending Msg: Message payload is empty or undefined');
SetStatus("Message empty", "red");
setTimeout(() => SetStatus('Connected','green'), 3000);
return;
}
if (node.waClient.clientType === "waWebClient"){
try {
numb = await formatChatNumber(numb, node.waClient, node);
if(typeof inputMessage === "object"){
// Ensure message is a string for simple messages
if(typeof inputMessage === "object" && inputMessage.buttons){
inputMessage = new Buttons(inputMessage.text, inputMessage.buttons, "text" ,inputMessage.footer);
await node.waClient.sendMessage(numb, inputMessage);
} else if (typeof inputMessage === "object") {
// If it's an object without buttons, convert to string or handle appropriately
const messageText = inputMessage.text || JSON.stringify(inputMessage);
await node.waClient.sendMessage(numb, messageText);
} else {
// Convert to string to ensure valid message
await node.waClient.sendMessage(numb, String(inputMessage));
}
await node.waClient.sendMessage(numb, inputMessage);
}
catch(e){
node.error(`Error Sending Msg: ${e}`);
@@ -36,9 +53,15 @@ module.exports = function(RED) {
try {
let client = await node.waClient;
numb = await formatChatNumberSocket(numb, node.waClient, node);
if (typeof inputMessage ==="string"){
// Format message for socket client
if (typeof inputMessage === "string"){
inputMessage = {text : inputMessage};
} else if (typeof inputMessage === "object" && !inputMessage.text) {
// If object doesn't have text property, convert to string
inputMessage = {text : JSON.stringify(inputMessage)};
}
await client.sendMessage(numb, inputMessage);
}
catch(e) {

View File

@@ -20,14 +20,29 @@ module.exports = function(RED) {
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
async function whatsappMessage(gID , inputMessage){
// Validate message
if (!inputMessage) {
node.error('Error Sending Msg: Message payload is empty or undefined');
SetStatus("Message empty", "red");
setTimeout(() => SetStatus('Connected','green'), 3000);
return;
}
if (node.waClient.clientType === "waWebClient"){
try {
gID = await formatGroupId(gID, node.waClient, node);
if(typeof inputMessage === "object"){
// Ensure message is a string for simple messages
if(typeof inputMessage === "object" && inputMessage.buttons){
inputMessage = new Buttons(inputMessage.text, inputMessage.buttons, "text" ,inputMessage.footer);
await node.waClient.sendMessage(gID, inputMessage);
} else if (typeof inputMessage === "object") {
// If it's an object without buttons, convert to string or handle appropriately
const messageText = inputMessage.text || JSON.stringify(inputMessage);
await node.waClient.sendMessage(gID, messageText);
} else {
await node.waClient.sendMessage(gID, inputMessage);
// Convert to string to ensure valid message
await node.waClient.sendMessage(gID, String(inputMessage));
}
}
catch(e){
@@ -38,9 +53,15 @@ module.exports = function(RED) {
try {
let client = await node.waClient;
gID = await formatGroupIdSocket(gID, node.waClient, node);
if (typeof inputMessage ==="string"){
// Format message for socket client
if (typeof inputMessage === "string"){
inputMessage = {text : inputMessage};
} else if (typeof inputMessage === "object" && !inputMessage.text) {
// If object doesn't have text property, convert to string
inputMessage = {text : JSON.stringify(inputMessage)};
}
await client.sendMessage(gID, inputMessage);
}
catch(e) {

View File

@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-whatsapp-link",
"version": "1.0.40-local.1",
"version": "1.0.41",
"description": "Node to send and receive whatsapp messages in groups and chats. | No third party APIs",
"repository": {
"type": "git",
@@ -27,17 +27,22 @@
"whatsapp group-out": "group-out.js",
"whatsapp reply": "whatsappReply.js",
"whatsapp Link": "whatsappLink.js",
"number-recipient": "numberRecipient.js",
"group-recipient": "groupRecipient.js"
"whatsapp numberRecipient": "numberRecipient.js",
"whatsapp groupRecipient": "groupRecipient.js"
}
},
"dependencies": {
"@whiskeysockets/baileys": "latest",
"pino": "latest",
"qrcode": "^1.5.1",
"whatsapp-web.js": "^1.22.2-alpha.1"
"@whiskeysockets/baileys": "^6.7.9",
"pino": "^9.5.0",
"qrcode": "^1.5.4",
"whatsapp-web.js": "^1.26.0"
},
"overrides": {
"inflight": "npm:@aashutoshrathi/inflight@^1.0.2",
"glob": "^10.3.10",
"rimraf": "^5.0.5"
},
"engines": {
"node": ">=8.0.0"
"node": ">=18.0.0"
}
}