node-red-contrib-whatsapp-link
Advanced tools
Comparing version 0.1.16 to 0.1.18
{ | ||
"name": "node-red-contrib-whatsapp-link", | ||
"version": "0.1.16", | ||
"version": "0.1.18", | ||
"description": "Whatsapp connection with Node-Red | No third party APIs", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -36,2 +36,3 @@ # Whatsapp Link :iphone: | ||
| 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. | ||
@@ -47,3 +48,3 @@ | ||
*Try to send `!nodered` to connected whatsapp number and get a `Hi` in reply from Node-Red.* | ||
*Try to send a message `!nodered` to connected whatsapp number and get a `Hi` in reply from Node-Red.* | ||
@@ -50,0 +51,0 @@ 3. **Whatsapp Out** : As simple as mention on name, node will send `msg.payload` recived at input to the number mentioned in node. |
@@ -6,3 +6,3 @@ module.exports = function(RED) { | ||
node.number = config.number; | ||
node.number = node.number.match(/\d+/); | ||
node.number = node.number.replace(/\D/g, ''); | ||
//node.number = this.number.includes('@c.us') ? this.number : `${this.number}@c.us`; | ||
@@ -14,3 +14,8 @@ node.number = `${node.number}@c.us`; | ||
node.on('input', (message)=> { | ||
node.waClient.sendMessage(this.number, message.payload); | ||
try { | ||
node.waClient.sendMessage(node.number, message.payload); | ||
} | ||
catch(e) { | ||
node.log(`Error Sending Msg: ${e}`); | ||
}; | ||
}); | ||
@@ -17,0 +22,0 @@ |
@@ -39,11 +39,17 @@ module.exports = function(RED) { | ||
//Group Add/leave status----- | ||
node.waClient.on('group_join', (msg)=>{ | ||
node.waClient.on('group_join', async (notification)=>{ | ||
msg.chat = await notification.getChat(); | ||
msg.payload = msg.chat.name; | ||
msg.type = notification.type; | ||
msg.notification = notification; | ||
node.send(msg); | ||
console.log(msg); | ||
msg.reply('!Node-Red joined'); | ||
notification.reply('!Node-Red joined'); | ||
}); | ||
node.waClient.on('group_leave', (msg)=>{ | ||
node.waClient.on('group_leave', async (notification)=>{ | ||
msg.chat = await notification.getChat(); | ||
msg.payload = msg.chat.name; | ||
msg.type = notification.type; | ||
msg.notification = notification; | ||
node.send(msg); | ||
msg.reply('!Node-Red leave'); | ||
}); | ||
@@ -50,0 +56,0 @@ |
@@ -23,3 +23,3 @@ module.exports = function(RED) { | ||
WAnode.log(`Error : ${e}`); | ||
WARestart(); | ||
WAnode.log(`Error : Unable to start Whatsapp. Try Again..`); | ||
}; | ||
@@ -26,0 +26,0 @@ |
18446
244
65