node-red-contrib-whatsapp-link
Advanced tools
Comparing version 0.1.15 to 0.1.16
{ | ||
"name": "node-red-contrib-whatsapp-link", | ||
"version": "0.1.15", | ||
"version": "0.1.16", | ||
"description": "Whatsapp connection with Node-Red | No third party APIs", | ||
@@ -5,0 +5,0 @@ "scripts": { |
# 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. | ||
Currently in developing mode, Continous updated may encounter. :sweat_smile: | ||
@@ -24,4 +24,4 @@ ## To Connect with Whatsapp | ||
| 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. | | ||
@@ -40,7 +40,11 @@ --- | ||
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` and sender number can be read at `msg.from`. | ||
- 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. | ||
*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. | ||
@@ -47,0 +51,0 @@ |
@@ -6,3 +6,5 @@ module.exports = function(RED) { | ||
node.number = config.number; | ||
node.number = this.number.includes('@c.us') ? this.number : `${this.number}@c.us`; | ||
node.number = node.number.match(/\d+/); | ||
//node.number = this.number.includes('@c.us') ? this.number : `${this.number}@c.us`; | ||
node.number = `${node.number}@c.us`; | ||
var whatsappLinkNode = RED.nodes.getNode(config.whatsappLink); | ||
@@ -33,7 +35,4 @@ node.waClient = whatsappLinkNode.client; | ||
node.waClient.on('loading_screen', (percentage, topic) => { | ||
node.waClient.on('loading_screen', () => { | ||
SetStatus('Connecting...','yellow'); | ||
msg.payload = percentage; | ||
msg.topic = topic; | ||
node.send(msg); | ||
}); | ||
@@ -40,0 +39,0 @@ |
@@ -18,4 +18,3 @@ module.exports = function(RED) { | ||
// Commands recived for Whatsapp Client. | ||
// Commands recived for Whatsapp Admin. | ||
this.on('input', async function(msg, send){ | ||
@@ -40,2 +39,19 @@ if (msg.payload === "destroy") { | ||
//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---- | ||
@@ -42,0 +58,0 @@ node.waClient.on('qr', (qr) => { |
@@ -23,2 +23,3 @@ module.exports = function(RED) { | ||
WAnode.log(`Error : ${e}`); | ||
WARestart(); | ||
}; | ||
@@ -40,4 +41,9 @@ | ||
async function WAClose(){ | ||
await client.destroy(); | ||
function WAClose(){ | ||
try { | ||
client.destroy(); | ||
} | ||
catch(e){ | ||
WAnode.err(`Error : Too many instructions! Try again.`) | ||
} | ||
}; | ||
@@ -83,3 +89,2 @@ | ||
this.client = client; | ||
this.WARestart = WARestart; | ||
@@ -86,0 +91,0 @@ this.whatsappConnectionStatus = whatsappConnectionStatus; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
17727
233
64