node-red-contrib-whatsapp-link
Advanced tools
Comparing version 0.1.1 to 0.1.2-7.1
{ | ||
"name": "node-red-contrib-whatsapp-link", | ||
"version": "0.1.1", | ||
"description": "Whatsapp connection with Node-Red", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"version": "0.1.27.1", | ||
"description": "Node to send and recive whatsapp chats and group messages. | No third party APIs", | ||
"repository": { | ||
@@ -18,3 +15,5 @@ "type": "git", | ||
"whatsapp", | ||
"message" | ||
"message", | ||
"whatsapp Group", | ||
"whatsapp Chat" | ||
], | ||
@@ -24,6 +23,8 @@ "author": "Ravi Mishra", | ||
"node-red": { | ||
"version": ">=2.0", | ||
"nodes": { | ||
"whatsapp admin": "whatsappAdmin.js", | ||
"whatsapp in": "whatsapp-in.js", | ||
"whatsapp Out": "whatsapp-out.js", | ||
"whatsapp admin": "admin.js", | ||
"whatsapp chats-in": "chats-in.js", | ||
"whatsapp chats-out": "chats-out.js", | ||
"whatsapp group-out": "group-out.js", | ||
"whatsapp Link": "whatsappLink.js" | ||
@@ -33,5 +34,9 @@ } | ||
"dependencies": { | ||
"puppeteer": "latest", | ||
"qrcode": "^1.5.1", | ||
"whatsapp-web.js": "^1.18.4" | ||
}, | ||
"engines": { | ||
"node": ">=8.0.0" | ||
} | ||
} |
@@ -1,3 +0,84 @@ | ||
# Whatsapp Bot | ||
# Whatsapp Link :iphone: | ||
Simple Node for connecting Node-Red to Whatsapp. | ||
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. | ||
## To Connect with Whatsapp | ||
![](./.github/admin_login.gif) | ||
1. Deploy whatsapp admin node (along with whatsappLink node). | ||
2. whatsappLink node will initilize, connect with whatsapp and generate a <b>QR code below the Admin Node </b> (in terminal also). | ||
3. Scan the QR code with your Whatsapp Mobile App (Go to settings > Linked device > Scan & Connect). | ||
4. Done - Whatsapp Connected. | ||
*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* | ||
## Nodes | ||
1. **Whatsapp Admin** : Node used for first time users to connect with whatsapp and other admin related tasks. </br> | ||
Admin Node generate QR Code just below the node for easy connection with whatsapp. | ||
| Inputs | Description | | ||
|--------|-------------- | | ||
| test | Checks the current status of whatsapp and output the same in `msg.payload`| | ||
| destroy| Close the client and destroy the whatsapp connection.| | ||
| restart | Restart the whatsapp connection. | | ||
| logout | Simply log you out and close the session. | | ||
--- | ||
| Output | Description | | ||
|--------| ------------| | ||
|`status` | provide status on `msg.payload` for all and each input mentioned in above table. | | ||
| Connecting..| When whatsapp attempting to connect. | ||
| QR Code (image) | when QR code is generated. *This method can also be used to get QR Code (image) generated by whatsapp.* | ||
| Connected | When whatapp is sucessfully connected.| | ||
| Group Joined or Removed | `msg.paylod` : Group Name. </br> `msg.type` : joined / Removed from group.</br> `msg.notification` : Complete notification. </br> `msg.chat` : Complete Group Details. | ||
2. **Chats 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. | ||
| Output | Description | | ||
|--------|-------------| | ||
| `msg.paylod` | Recived message | | ||
| `msg.from` | Sender Number | | ||
| `msg.chatID` | Chat ID of Group chat / Personal chat | | ||
| `msg.message` | Complete message object. <br />*Some extra details for advance users* | | ||
3. **Chats 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. | ||
The node will send recived `msg.payload` to a group chat. | ||
## 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. | ||
* `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. | ||
## Future Nodes | ||
Currently working on more Whatsapp Node and will be avilable soon - | ||
1. Group Message Node (Working). | ||
2. Chat Reply node. | ||
3. Instruction (smart) Reply Node. | ||
Complete detail for Nodes will also be updated as soon as possible. | ||
>Please don`t try to spam with your personal Number, Suspicious activities might be tracked by whatsapp. | ||
Thanks to bear with me |
module.exports = function(RED) { | ||
const { Client, LocalAuth } = require('whatsapp-web.js'); | ||
const QRCode = require('qrcode'); | ||
const OS = require('os'); | ||
const Path = require('path'); | ||
function RemoteClientNode(n) { | ||
let userDir = OS.homedir(); | ||
let whatsappLinkDir = Path.join(userDir, '.node-red', 'Whatsapp-Link'); | ||
function RemoteClientNode(n) { | ||
RED.nodes.createNode(this,n); | ||
let WAnode = this; | ||
WAnode.client = n.cName; | ||
let WAClientID = `${n.cName}ID`; | ||
WAnode.client = new Client({ | ||
let whatsappConnectionStatus; | ||
const client = new Client({ | ||
authStrategy : new LocalAuth({ | ||
clientId : WAClientID | ||
dataPath : whatsappLinkDir | ||
}), | ||
puppeteer : {headless : true } | ||
puppeteer : { | ||
headless : true, | ||
args : ['--no-sandbox', '--disable-setuid-sandbox'] | ||
} | ||
}); | ||
let WAConnect = function(){ | ||
try { | ||
client.initialize(); | ||
WAnode.log("Status : Initializing Whatsapp.."); | ||
} | ||
catch(e) { | ||
WAnode.log(`Error : Unable to start Whatsapp. Try Again..`); | ||
}; | ||
let WAConnect = function(){ | ||
WAnode.client.initialize(); | ||
WAnode.log("Connecting to Whatsapp.."); | ||
client.on("qr", (qr)=>{ | ||
clearInterval(connectionSetupID); | ||
QRCode.toString(qr, {type : 'terminal', small:true }, function(err, QRTerminal){ | ||
WAnode.log(`To Connect, Scan the QR Code through your Whatsapp Mobile App.`) | ||
console.log(""); | ||
console.log(QRTerminal); | ||
}); | ||
}); | ||
client.on("ready", ()=>{ | ||
WAnode.log(`Status : Whatsapp Connected`); | ||
}); | ||
}; | ||
WAConnect(); | ||
let WARestart = function(){ | ||
WAnode.client.destroy(); | ||
WAnode.client.initialize(); | ||
function WAClose(){ | ||
try { | ||
client.destroy(); | ||
} | ||
catch(e){ | ||
WAnode.err(`Error : Too many instructions! Try again.`) | ||
} | ||
}; | ||
async function connectionSetup(){ | ||
try { | ||
whatsappConnectionStatus = await client.getState(); | ||
if(whatsappConnectionStatus === "CONNECTED"){ | ||
clearInterval(connectionSetupID); | ||
} | ||
else { | ||
WAnode.log(`Status : Connecting to Whatsapp...`); | ||
} | ||
} | ||
catch(e){ | ||
WAnode.log(`Error : Connection is slow...`); | ||
} | ||
}; | ||
let connectionSetupID = setInterval(connectionSetup, 10000); | ||
let WARestart = async function(){ | ||
await client.destroy(); | ||
await client.initialize(); | ||
} | ||
this.on('close', (removed, done)=>{ | ||
if(!removed){ | ||
console.log(`closing WA admin closing in new line also`) | ||
async function distroyWA() { | ||
await WAnode.client.destroy(); | ||
}; | ||
distroyWA(); | ||
if(removed){ | ||
clearInterval(connectionSetupID); | ||
WAClose(); | ||
} | ||
else { | ||
clearInterval(connectionSetupID); | ||
WAClose(); | ||
} | ||
done(); | ||
}); | ||
//this.client = client ; | ||
this.WAConnect = WAConnect; | ||
this.client = client; | ||
this.WARestart = WARestart; | ||
this.whatsappConnectionStatus = whatsappConnectionStatus; | ||
} | ||
RED.nodes.registerType("whatsappLink",RemoteClientNode); | ||
} |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
171910
14
313
85
3
1
+ Addedpuppeteer@latest
+ Added@babel/code-frame@7.24.2(transitive)
+ Added@babel/helper-validator-identifier@7.24.5(transitive)
+ Added@babel/highlight@7.24.5(transitive)
+ Added@puppeteer/browsers@2.2.3(transitive)
+ Added@tootallnate/quickjs-emscripten@0.23.0(transitive)
+ Addedagent-base@7.1.1(transitive)
+ Addedansi-styles@3.2.1(transitive)
+ Addedargparse@2.0.1(transitive)
+ Addedast-types@0.13.4(transitive)
+ Addedb4a@1.6.6(transitive)
+ Addedbare-events@2.2.2(transitive)
+ Addedbare-fs@2.3.0(transitive)
+ Addedbare-os@2.3.0(transitive)
+ Addedbare-path@2.1.2(transitive)
+ Addedbare-stream@1.0.0(transitive)
+ Addedbasic-ftp@5.0.5(transitive)
+ Addedcallsites@3.1.0(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedchromium-bidi@0.5.19(transitive)
+ Addedcliui@8.0.1(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedcosmiconfig@9.0.0(transitive)
+ Addeddata-uri-to-buffer@6.0.2(transitive)
+ Addeddegenerator@5.0.1(transitive)
+ Addeddevtools-protocol@0.0.1286932(transitive)
+ Addedenv-paths@2.2.1(transitive)
+ Addederror-ex@1.3.2(transitive)
+ Addedescalade@3.1.2(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedescodegen@2.1.0(transitive)
+ Addedesprima@4.0.1(transitive)
+ Addedestraverse@5.3.0(transitive)
+ Addedesutils@2.0.3(transitive)
+ Addedfast-fifo@1.3.2(transitive)
+ Addedfs-extra@11.2.0(transitive)
+ Addedget-uri@6.0.3(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedhttp-proxy-agent@7.0.2(transitive)
+ Addedhttps-proxy-agent@7.0.4(transitive)
+ Addedimport-fresh@3.3.0(transitive)
+ Addedip-address@9.0.5(transitive)
+ Addedis-arrayish@0.2.1(transitive)
+ Addedjs-tokens@4.0.0(transitive)
+ Addedjs-yaml@4.1.0(transitive)
+ Addedjsbn@1.1.0(transitive)
+ Addedjson-parse-even-better-errors@2.3.1(transitive)
+ Addedlines-and-columns@1.2.4(transitive)
+ Addedlru-cache@6.0.07.18.3(transitive)
+ Addedmitt@3.0.1(transitive)
+ Addednetmask@2.0.2(transitive)
+ Addedpac-proxy-agent@7.0.1(transitive)
+ Addedpac-resolver@7.0.1(transitive)
+ Addedparent-module@1.0.1(transitive)
+ Addedparse-json@5.2.0(transitive)
+ Addedpicocolors@1.0.1(transitive)
+ Addedproxy-agent@6.4.0(transitive)
+ Addedpuppeteer@22.9.0(transitive)
+ Addedpuppeteer-core@22.9.0(transitive)
+ Addedqueue-tick@1.0.1(transitive)
+ Addedresolve-from@4.0.0(transitive)
+ Addedsemver@7.6.0(transitive)
+ Addedsmart-buffer@4.2.0(transitive)
+ Addedsocks@2.8.3(transitive)
+ Addedsocks-proxy-agent@8.0.3(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedsprintf-js@1.1.3(transitive)
+ Addedstreamx@2.16.1(transitive)
+ Addedsupports-color@5.5.0(transitive)
+ Addedtar-fs@3.0.5(transitive)
+ Addedtar-stream@3.1.7(transitive)
+ Addedtslib@2.6.2(transitive)
+ Addedurlpattern-polyfill@10.0.0(transitive)
+ Addedwrap-ansi@7.0.0(transitive)
+ Addedws@8.17.0(transitive)
+ Addedy18n@5.0.8(transitive)
+ Addedyallist@4.0.0(transitive)
+ Addedyargs@17.7.2(transitive)
+ Addedyargs-parser@21.1.1(transitive)
+ Addedzod@3.22.4(transitive)