From 79331bbedc7b9b88f8a8ec89d62ac18d52b39403 Mon Sep 17 00:00:00 2001 From: rawee Date: Fri, 9 Dec 2022 11:44:12 +0530 Subject: [PATCH] Chats-out Updated --- README.md | 11 +++++------ whatsapp-out.js | 5 +---- whatsappAdmin.js | 17 +++++++++++++++++ whatsappLink.js | 1 + 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 3374d90..f65f6e9 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,8 @@ Currently in developing mode, Continous updated may encounter. :sweat_smile: | Inputs | Description | |--------|-------------- | | test | Checks the current status of whatsapp and output the same in `msg.payload`| - | destroy| Close the client and destroy the connection.| - | restart | Restart the whatsapp client | + | destroy| Close the client and destroy the whatsapp connection.| + | restart | Restart the whatsapp connection. | | logout | Simply log you out and close the session. | --- @@ -36,15 +36,14 @@ Currently in developing mode, Continous updated may encounter. :sweat_smile: 2. **Whatsapp In** : Node to recive all messages send to connected number. - - Simply deploy the node and wait for connected (green) status. + - Simply deploy the node and wait for green (connected) status. - After succesfully connection, Node is able to recive all messages. - Messages can be read at `msg.payload` and `msg.body`. - Sender number can be read at `msg.from`. - Please look complete `{msg}` to get all details about recived message. - | TEST | - | -----| - | Try to send `!nodered` to connected whatsapp number and get a `Hi` in reply from Node-Red. + +*Try to send `!nodered` to connected whatsapp number and get a `Hi` in reply from Node-Red.* 3. **Whatsapp Out** : As simple as mention on name, node will send `msg.payload` recived at input to the number mentioned in node. diff --git a/whatsapp-out.js b/whatsapp-out.js index f14a451..43175ba 100644 --- a/whatsapp-out.js +++ b/whatsapp-out.js @@ -31,11 +31,8 @@ module.exports = function(RED) { SetStatus('Not Connected','red'); }); - node.waClient.on('loading_screen', (percentage, topic) => { + node.waClient.on('loading_screen', () => { SetStatus('Connecting...','yellow'); - msg.payload = percentage; - msg.topic = topic; - node.send(msg); }); node.waClient.on('ready', () => { diff --git a/whatsappAdmin.js b/whatsappAdmin.js index 6eb0654..721a354 100644 --- a/whatsappAdmin.js +++ b/whatsappAdmin.js @@ -35,6 +35,23 @@ module.exports = function(RED) { }; }); + //Group Add/leave status----- + node.waClient.on('group_join', (msg)=>{ + node.send(msg); + console.log(msg); + msg.reply('!Node-Red joined'); + }); + + node.waClient.on('group_leave', (msg)=>{ + node.send(msg); + msg.reply('!Node-Red leave'); + }); + + node.waClient.on('group_update', (msg)=>{ + node.send(msg); + }); + + //whatsapp Status Parameters---- node.waClient.on('qr', (qr) => { SetStatus("QR Code Generated", "yellow"); diff --git a/whatsappLink.js b/whatsappLink.js index 7215958..a87027f 100644 --- a/whatsappLink.js +++ b/whatsappLink.js @@ -20,6 +20,7 @@ module.exports = function(RED) { } catch(e) { WAnode.log(`Error : ${e}`); + WARestart(); }; client.on("qr", (qr)=>{