Group Node Added
This commit is contained in:
parent
c9be90fc9b
commit
3c102f3258
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "node-red-contrib-whatsapp-link",
|
"name": "node-red-contrib-whatsapp-link",
|
||||||
"version": "0.1.19",
|
"version": "0.1.21",
|
||||||
"description": "Whatsapp connection with Node-Red | No third party APIs",
|
"description": "Whatsapp connection with Node-Red | No third party APIs",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
@ -25,7 +25,8 @@
|
|||||||
"whatsapp admin": "whatsappAdmin.js",
|
"whatsapp admin": "whatsappAdmin.js",
|
||||||
"whatsapp in": "whatsapp-in.js",
|
"whatsapp in": "whatsapp-in.js",
|
||||||
"whatsapp Out": "whatsapp-out.js",
|
"whatsapp Out": "whatsapp-out.js",
|
||||||
"whatsapp Link": "whatsappLink.js"
|
"whatsapp Link": "whatsappLink.js",
|
||||||
|
"Group Out": "whatsapp-Gout.js"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -33,6 +34,6 @@
|
|||||||
"whatsapp-web.js": "^1.18.4"
|
"whatsapp-web.js": "^1.18.4"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node" : ">=8.0.0"
|
"node": ">=8.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
55
whatsapp-Gout.js
Normal file
55
whatsapp-Gout.js
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
module.exports = function(RED) {
|
||||||
|
function WhatsappGroupOut(config) {
|
||||||
|
RED.nodes.createNode(this,config);
|
||||||
|
var node = this;
|
||||||
|
node.gID = config.gID;
|
||||||
|
node.gID = node.gID.replace(/\D/g, '');
|
||||||
|
//node.number = this.number.includes('@c.us') ? this.number : `${this.number}@c.us`;
|
||||||
|
node.gID = `${node.gID}@g.us`;
|
||||||
|
var whatsappLinkNode = RED.nodes.getNode(config.whatsappLink);
|
||||||
|
node.waClient = whatsappLinkNode.client;
|
||||||
|
|
||||||
|
node.on('input', (message)=> {
|
||||||
|
try {
|
||||||
|
node.waClient.sendMessage(node.gID, message.payload);
|
||||||
|
}
|
||||||
|
catch(e) {
|
||||||
|
node.log(`Error Sending Msg: ${e}`);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function SetStatus(WAStatus, color){
|
||||||
|
node.status({fill:color,shape:"dot",text:WAStatus});
|
||||||
|
};
|
||||||
|
|
||||||
|
//whatsapp Status Parameters----
|
||||||
|
node.waClient.on('qr', (qr) => {
|
||||||
|
SetStatus("QR Code Generated", "yellow");
|
||||||
|
// QRCode.toDataURL(qr, function(err, url){
|
||||||
|
// msg = {payload : url};
|
||||||
|
// node.send(msg);
|
||||||
|
// });
|
||||||
|
});
|
||||||
|
|
||||||
|
node.waClient.on('auth_failure', () => {
|
||||||
|
SetStatus('Not Connected','red');
|
||||||
|
});
|
||||||
|
|
||||||
|
node.waClient.on('loading_screen', () => {
|
||||||
|
SetStatus('Connecting...','yellow');
|
||||||
|
});
|
||||||
|
|
||||||
|
node.waClient.on('ready', () => {
|
||||||
|
SetStatus('Connected','green');
|
||||||
|
});
|
||||||
|
|
||||||
|
node.waClient.on('disconnected', () => {
|
||||||
|
SetStatus("Disconnected","red");
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
RED.nodes.registerType("whatsapp-Gout", WhatsappGroupOut);
|
||||||
|
}
|
||||||
@ -26,10 +26,10 @@ module.exports = function(RED) {
|
|||||||
//whatsapp Status Parameters----
|
//whatsapp Status Parameters----
|
||||||
node.waClient.on('qr', (qr) => {
|
node.waClient.on('qr', (qr) => {
|
||||||
SetStatus("QR Code Generated", "yellow");
|
SetStatus("QR Code Generated", "yellow");
|
||||||
QRCode.toDataURL(qr, function(err, url){
|
// QRCode.toDataURL(qr, function(err, url){
|
||||||
msg = {payload : url};
|
// msg = {payload : url};
|
||||||
node.send(msg);
|
// node.send(msg);
|
||||||
});
|
// });
|
||||||
});
|
});
|
||||||
|
|
||||||
node.waClient.on('auth_failure', () => {
|
node.waClient.on('auth_failure', () => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user