Group Node Added
This commit is contained in:
parent
3c102f3258
commit
bd29ae2a59
27
README.md
27
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.
|
2. **Whatsapp In** : Node to recive all messages send to connected number.
|
||||||
- Simply deploy the node and wait for green (connected) status.
|
- Simply deploy the node and wait for green (connected) status.
|
||||||
- After succesfully connection, Node is able to recive all messages.
|
- 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 :
|
| Output | Description |
|
||||||
*Connect Whatsapp IN Node and try to send a message `!nodered` to connected whatsapp number and get a `Hi` in reply from Node-Red.*
|
|--------|-------------|
|
||||||
|
| `msg.paylod` | Recived message |
|
||||||
|
| `msg.from` | Sender Number |
|
||||||
|
| `msg.message` | Complete message object. <br />*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.
|
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.*
|
*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
|
## Future Nodes
|
||||||
Currently working on more Whatsapp Node and will be avilable soon -
|
Currently working on more Whatsapp Node and will be avilable soon -
|
||||||
|
|
||||||
1. Group Message Node.
|
1. Group Message Node (Working).
|
||||||
2. Chat Reply node.
|
2. Chat Reply node.
|
||||||
3. Instruction (smart) Reply Node.
|
3. Instruction (smart) Reply Node.
|
||||||
|
|
||||||
|
|||||||
11
package-lock.json
generated
11
package-lock.json
generated
@ -1,16 +1,19 @@
|
|||||||
{
|
{
|
||||||
"name": "whatsapp-bot",
|
"name": "node-red-contrib-whatsapp-link",
|
||||||
"version": "0.1.1",
|
"version": "0.1.201",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "whatsapp-bot",
|
"name": "node-red-contrib-whatsapp-link",
|
||||||
"version": "0.1.1",
|
"version": "0.1.201",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"qrcode": "^1.5.1",
|
"qrcode": "^1.5.1",
|
||||||
"whatsapp-web.js": "^1.18.4"
|
"whatsapp-web.js": "^1.18.4"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@pedroslopez/moduleraid": {
|
"node_modules/@pedroslopez/moduleraid": {
|
||||||
|
|||||||
49
whatsapp-Gout.html
Normal file
49
whatsapp-Gout.html
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<script type="text/javascript">
|
||||||
|
RED.nodes.registerType('whatsapp-Gout',{
|
||||||
|
category: 'whatsapp',
|
||||||
|
color: '#25D366',
|
||||||
|
defaults: {
|
||||||
|
name: {value:"Group Message"},
|
||||||
|
whatsappLink: {value:"whatsapp-web", type:'whatsappLink'},
|
||||||
|
gID: {value: ""}
|
||||||
|
},
|
||||||
|
outputs:0,
|
||||||
|
inputs:1,
|
||||||
|
icon: 'font-awesome/fa-commenting',
|
||||||
|
align: 'right',
|
||||||
|
label: function() {
|
||||||
|
return this.name||"Whatsapp Group";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/html" data-template-name="whatsapp-Gout">
|
||||||
|
<div class="form-row">
|
||||||
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
||||||
|
<input type="text" id="node-input-name" placeholder="Name">
|
||||||
|
</div>
|
||||||
|
<div class="form-row">
|
||||||
|
<label for="node-input-whatsappLink"><i class="fa fa-tag"></i> Client</label>
|
||||||
|
<input type="text" id="node-input-whatsappLink" placeholder="Name">
|
||||||
|
</div>
|
||||||
|
<div class="form-row">
|
||||||
|
<label for="node-input-gID"><i class="fa fa-tag"></i> Number</label>
|
||||||
|
<input type="text" id="node-input-gID" placeholder="Group Chat ID..">
|
||||||
|
</div>
|
||||||
|
<div class="form-tips">
|
||||||
|
<p>Group Chat IDs are numbers given to each Chats in Whatsapp, <br>
|
||||||
|
- For every message recived from Whatsapp-IN-Node, Chat ID can be seen at <b>msg.chatID</b>.<br>
|
||||||
|
<b>Or</b><br>
|
||||||
|
- Chat ID of group can recive from whatsapp-Admin-Node whenever the new group joined.<br>
|
||||||
|
</div>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
<script type="text/html" data-help-name="whatsapp-Gout">
|
||||||
|
<p>Whatsapp Group Node to send message in a Group.</p>
|
||||||
|
<p>Chat IDs are numbers given to each chats including group chats in whatsapp, <br>
|
||||||
|
- For every message recived from Whatsapp-IN-Node, Chat ID can be seen at <b>msg.chatID</b>.<br>
|
||||||
|
<b>Or</b><br>
|
||||||
|
- Chat ID of group can recive from whatsapp-Admin-Node whenever the new group joined.<br>
|
||||||
|
|
||||||
|
</script>
|
||||||
@ -12,26 +12,23 @@ module.exports = function(RED) {
|
|||||||
node.status({fill:color,shape:"dot",text:WAStatus});
|
node.status({fill:color,shape:"dot",text:WAStatus});
|
||||||
};
|
};
|
||||||
|
|
||||||
node.waClient.on('message', async msg => {
|
node.waClient.on('message', async message => {
|
||||||
msg.payload = msg.body;
|
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);
|
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----
|
//whatsapp Status Parameters----
|
||||||
node.waClient.on('qr', (qr) => {
|
node.waClient.on('qr', (qr) => {
|
||||||
SetStatus("QR Code Generated", "yellow");
|
SetStatus("QR Code Generated", "yellow");
|
||||||
QRCode.toDataURL(qr, function(err, url){
|
// QRCode.toDataURL(qr, function(err, url){
|
||||||
msg = {payload : url};
|
// msg = {payload : url};
|
||||||
node.send(msg);
|
// node.send(msg);
|
||||||
});
|
// });
|
||||||
});
|
});
|
||||||
|
|
||||||
node.waClient.on('auth_failure', () => {
|
node.waClient.on('auth_failure', () => {
|
||||||
|
|||||||
@ -38,6 +38,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<script type="text/markdown" data-help-name="whatsapp-out">
|
<script type="text/markdown" data-help-name="whatsapp-out">
|
||||||
|
Node to send whatsapp messages.
|
||||||
As simple as mention on name, node will send `msg.payload` recived at input to the number mentioned in node.
|
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.*
|
-*Don't forget to mention international dialing code befor your number. Number must be in format like `+11 99999 99999` without any space.*
|
||||||
|
|||||||
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<script type="text/markdown" data-help-name="whatsapp-admin">
|
<script type="text/markdown" data-help-name="whatsapp-admin">
|
||||||
Node used for basic status of whatsapp.
|
Node used for Admin related tasks of whatsapp.
|
||||||
|
|
||||||
| Inputs | Description |
|
| Inputs | Description |
|
||||||
|--------|-------------- |
|
|--------|-------------- |
|
||||||
|
|||||||
@ -39,6 +39,7 @@ module.exports = function(RED) {
|
|||||||
node.waClient.on('group_join', async (notification)=>{
|
node.waClient.on('group_join', async (notification)=>{
|
||||||
msg.chat = await notification.getChat();
|
msg.chat = await notification.getChat();
|
||||||
msg.payload = msg.chat.name;
|
msg.payload = msg.chat.name;
|
||||||
|
msg.chatID = msg.chat.id.user || `No ID Avilable`;
|
||||||
msg.type = notification.type;
|
msg.type = notification.type;
|
||||||
msg.notification = notification;
|
msg.notification = notification;
|
||||||
node.send(msg);
|
node.send(msg);
|
||||||
|
|||||||
@ -58,7 +58,7 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
catch(e){
|
catch(e){
|
||||||
WAnode.log(`Error : ${e}`);
|
WAnode.log(`Error : ${e}`);
|
||||||
WARestart();
|
WAnode.log(`Error : Need to restart the Node.`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let connectionSetupID = setInterval(connectionSetup, 10000);
|
let connectionSetupID = setInterval(connectionSetup, 10000);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user