Group Node Added

This commit is contained in:
rawee 2022-12-17 15:05:04 +05:30
parent 3c102f3258
commit bd29ae2a59
8 changed files with 92 additions and 26 deletions

View File

@ -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.
- 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`.
- 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 :
*Connect Whatsapp IN Node and try to send a message `!nodered` to connected whatsapp number and get a `Hi` in reply from Node-Red.*
| Output | Description |
|--------|-------------|
| `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.
*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
Currently working on more Whatsapp Node and will be avilable soon -
1. Group Message Node.
1. Group Message Node (Working).
2. Chat Reply node.
3. Instruction (smart) Reply Node.

11
package-lock.json generated
View File

@ -1,16 +1,19 @@
{
"name": "whatsapp-bot",
"version": "0.1.1",
"name": "node-red-contrib-whatsapp-link",
"version": "0.1.201",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "whatsapp-bot",
"version": "0.1.1",
"name": "node-red-contrib-whatsapp-link",
"version": "0.1.201",
"license": "ISC",
"dependencies": {
"qrcode": "^1.5.1",
"whatsapp-web.js": "^1.18.4"
},
"engines": {
"node": ">=8.0.0"
}
},
"node_modules/@pedroslopez/moduleraid": {

49
whatsapp-Gout.html Normal file
View 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>

View File

@ -12,26 +12,23 @@ module.exports = function(RED) {
node.status({fill:color,shape:"dot",text:WAStatus});
};
node.waClient.on('message', async msg => {
msg.payload = msg.body;
node.waClient.on('message', async message => {
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);
// 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----
node.waClient.on('qr', (qr) => {
SetStatus("QR Code Generated", "yellow");
QRCode.toDataURL(qr, function(err, url){
msg = {payload : url};
node.send(msg);
});
// QRCode.toDataURL(qr, function(err, url){
// msg = {payload : url};
// node.send(msg);
// });
});
node.waClient.on('auth_failure', () => {

View File

@ -38,6 +38,7 @@
<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.
-*Don't forget to mention international dialing code befor your number. Number must be in format like `+11 99999 99999` without any space.*

View File

@ -28,7 +28,7 @@
<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 |
|--------|-------------- |

View File

@ -39,6 +39,7 @@ module.exports = function(RED) {
node.waClient.on('group_join', async (notification)=>{
msg.chat = await notification.getChat();
msg.payload = msg.chat.name;
msg.chatID = msg.chat.id.user || `No ID Avilable`;
msg.type = notification.type;
msg.notification = notification;
node.send(msg);

View File

@ -58,7 +58,7 @@ module.exports = function(RED) {
}
catch(e){
WAnode.log(`Error : ${e}`);
WARestart();
WAnode.log(`Error : Need to restart the Node.`);
}
};
let connectionSetupID = setInterval(connectionSetup, 10000);