From 2fc45ac0ed0a0012e3efd7adc904f9c0a1a2cffb Mon Sep 17 00:00:00 2001 From: rawee Date: Sun, 1 Jan 2023 19:06:31 +0530 Subject: [PATCH] !nodered Added --- README.md | 15 ++++++++------- package.json | 5 ++--- whatsappLink.js | 27 +++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 3c69b3e..8b2e979 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ Simple node for connecting Node-Red to Whatsapp :iphone: -Currently in developing mode, Continous updated may encounter. :sweat_smile: -Missing Nodes ? : To avoid long names, Node names are updated. If some node are missing after update please re-configure the update node, it will not change again. +Currently in developing mode, Continous updated may encounter. :sweat_smile: + ## To Connect with Whatsapp ![](./.github/admin_login.gif) @@ -12,14 +12,14 @@ Missing Nodes ? : To avoid long names, Node names are updated. If some node are 2. whatsappLink node will initilize, connect with whatsapp and generate a QR code below the Admin Node (in terminal also). 3. Scan the QR code with your Whatsapp Mobile App (Go to settings > Linked device > Scan & Connect). 4. Done - Whatsapp Connected. +5. Send "`!nodered`" to get a reply from Node-Red in Chats/Groups. - *It will create a Whatsapp Web instance in your machine and store your session locally in Node-RED. All session is store in `.wwebjs_auth` folder* + *It will create a Whatsapp Web instance in your machine and store your session locally in Node-RED. All data are store in users `/.node-red/Whatsapp-Link` folder. Near you Node-Red's settings.js file.* - ## Nodes 1. **Whatsapp Admin** : Node used for first time users to connect with whatsapp and other admin related tasks.
-Admin Node generate QR Code just below the node for easy connection with whatsapp. +Admin Node generate QR Code just below the node for easy connection with whatsapp. @@ -68,12 +68,13 @@ Issues and Suggestions are welcome [here.](https://github.com/raweee/node-red-co * `Ver-0.1.21` : Group Message Node added. * `Ver-0.1.23` : Nodes are formatted correctly and names are updated. -* Working on QR Code to directlly avilable in run time on Whatsapp-Admin-Node. +* `Ver-0.1.28` : Now QR Codes are directlly avilable in run time on Whatsapp-Admin-Node. +* Working on Whatsapp Reply Node. ## Future Nodes Currently working on more Whatsapp Node and will be avilable soon - -1. Group Message Node (Working). +1. Group Message Node. 2. Chat Reply node. 3. Instruction (smart) Reply Node. diff --git a/package.json b/package.json index deaaf1b..0f41c1d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "node-red-contrib-whatsapp-link", - "version": "0.1.27.2", - "description": "Node to send and recive whatsapp chats and group messages. | No third party APIs", + "version": "0.1.28", + "description": "Node to send and receive whatsapp chats and group messages. | No third party APIs", "repository": { "type": "git", "url": "git+https://github.com/raweee/node-red-contrib-whatsapp-link.git" @@ -29,7 +29,6 @@ } }, "dependencies": { - "puppeteer": "latest", "qrcode": "^1.5.1", "whatsapp-web.js": "^1.18.4" }, diff --git a/whatsappLink.js b/whatsappLink.js index 42f436e..23d0c6e 100644 --- a/whatsappLink.js +++ b/whatsappLink.js @@ -30,6 +30,7 @@ module.exports = function(RED) { WAnode.log(`Error : Unable to start Whatsapp. Try Again..`); }; + //QR-Code on Terminal and Ready Status. client.on("qr", (qr)=>{ clearInterval(connectionSetupID); QRCode.toString(qr, {type : 'terminal', small:true }, function(err, QRTerminal){ @@ -44,6 +45,32 @@ module.exports = function(RED) { }; WAConnect(); + //Whatsapp-Link Test Features (For Status and Testing Only.) + client.on('message_create', async (msg)=> { + 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] + }); + } + + } + + }); + function WAClose(){ try { client.destroy();