From bd29ae2a59217e73e03d5312e968569170e35357 Mon Sep 17 00:00:00 2001 From: rawee Date: Sat, 17 Dec 2022 15:05:04 +0530 Subject: [PATCH] Group Node Added --- README.md | 27 +++++++++++++++++++------ package-lock.json | 11 +++++++---- whatsapp-Gout.html | 49 ++++++++++++++++++++++++++++++++++++++++++++++ whatsapp-in.js | 25 +++++++++++------------ whatsapp-out.html | 1 + whatsappAdmin.html | 2 +- whatsappAdmin.js | 1 + whatsappLink.js | 2 +- 8 files changed, 92 insertions(+), 26 deletions(-) create mode 100644 whatsapp-Gout.html diff --git a/README.md b/README.md index 04765e1..232449f 100644 --- a/README.md +++ b/README.md @@ -39,21 +39,36 @@ 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 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 Mode of Whatsapp In Node : -*Connect Whatsapp IN Node and try to send a message `!nodered` to connected whatsapp number and get a `Hi` in reply from Node-Red.* + | Output | Description | + |--------|-------------| + | `msg.paylod` | Recived message | + | `msg.from` | Sender Number | + | `msg.message` | Complete message object.
*Some extra details for advace users* | + 3. **Whatsapp Out** : As simple as mention on name, node will send `msg.payload` recived at input to the number mentioned in node. *Don't forget to mention international dialing code befor your number. Number must be in format like `+11 99999 99999` without any space.* +4. **Group Message** : Whatsapp Group Node to send message in a Group. + + *Chat IDs are numbers given to each chats including group chats in whatsapp* + +For every message recived from Whatsapp-IN-Node, Chat ID can be seen at `msg.chatID`, Copy the Chat ID of a group chat and paste it in Group-Message-Node to send group message in whatsapp. + + +## Issues & Updates +--- +Issues and Suggestions are welcome [here.](https://github.com/raweee/node-red-contrib-whatsapp-link/issues) + +* `Ver-0.1.21` : Group Message Node added. +* Working on QR Code to directlly avilable in run time on Whatsapp-Admin-Node. + ## Future Nodes Currently working on more Whatsapp Node and will be avilable soon - -1. Group Message Node. +1. Group Message Node (Working). 2. Chat Reply node. 3. Instruction (smart) Reply Node. diff --git a/package-lock.json b/package-lock.json index 39bac9e..6c7c22a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,16 +1,19 @@ { - "name": "whatsapp-bot", - "version": "0.1.1", + "name": "node-red-contrib-whatsapp-link", + "version": "0.1.201", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "whatsapp-bot", - "version": "0.1.1", + "name": "node-red-contrib-whatsapp-link", + "version": "0.1.201", "license": "ISC", "dependencies": { "qrcode": "^1.5.1", "whatsapp-web.js": "^1.18.4" + }, + "engines": { + "node": ">=8.0.0" } }, "node_modules/@pedroslopez/moduleraid": { diff --git a/whatsapp-Gout.html b/whatsapp-Gout.html new file mode 100644 index 0000000..5fe7f06 --- /dev/null +++ b/whatsapp-Gout.html @@ -0,0 +1,49 @@ + + + + + + diff --git a/whatsapp-in.js b/whatsapp-in.js index 137039f..090ecd7 100644 --- a/whatsapp-in.js +++ b/whatsapp-in.js @@ -12,26 +12,23 @@ module.exports = function(RED) { node.status({fill:color,shape:"dot",text:WAStatus}); }; - node.waClient.on('message', async msg => { - msg.payload = msg.body; + node.waClient.on('message', async message => { + let msg = {}; + msg.payload = message.body; + msg.from = message.author || message.from ; + msg.chatID = message.from.replace(/\D/g, ''); + msg.from = msg.from.replace(/\D/g, ''); + msg.message = message ; node.send(msg); - - // Whatsapp Chats testing text. - if(msg.body === '!nodered') { - var fromContact = msg.from.match(/\d+/); - msg.reply('Hi from Node-Red'); - msg.payload = `!nodered recieved from ${fromContact}.` - node.send(msg); - } }); //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); - }); + // QRCode.toDataURL(qr, function(err, url){ + // msg = {payload : url}; + // node.send(msg); + // }); }); node.waClient.on('auth_failure', () => { diff --git a/whatsapp-out.html b/whatsapp-out.html index 3935c0a..d3c644a 100644 --- a/whatsapp-out.html +++ b/whatsapp-out.html @@ -38,6 +38,7 @@