mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-21 13:09:15 +00:00
feat: Mention users, get user number from Contact model
This commit is contained in:
@@ -59,7 +59,7 @@ Take a look at [example.js](https://github.com/pedroslopez/whatsapp-web.js/blob/
|
|||||||
| Add group participants | ✅ |
|
| Add group participants | ✅ |
|
||||||
| Kick group participants | ✅ |
|
| Kick group participants | ✅ |
|
||||||
| Promote/demote group participants | ✅ |
|
| Promote/demote group participants | ✅ |
|
||||||
| Mention users | _pending_ |
|
| Mention users | ✅ |
|
||||||
| Get contact info | ✅ |
|
| Get contact info | ✅ |
|
||||||
| Get profile pictures | ✅ |
|
| Get profile pictures | ✅ |
|
||||||
| Set user status message | ✅ |
|
| Set user status message | ✅ |
|
||||||
|
|||||||
@@ -131,6 +131,12 @@ client.on('message', async msg => {
|
|||||||
const newStatus = msg.body.split(' ')[1];
|
const newStatus = msg.body.split(' ')[1];
|
||||||
await client.setStatus(newStatus);
|
await client.setStatus(newStatus);
|
||||||
msg.reply(`Status was updated to *${newStatus}*`);
|
msg.reply(`Status was updated to *${newStatus}*`);
|
||||||
|
} else if (msg.body == '!mention') {
|
||||||
|
const contact = await msg.getContact();
|
||||||
|
const chat = await msg.getChat();
|
||||||
|
chat.sendMessage(`Hi @${contact.number}!`, {
|
||||||
|
mentions: [contact]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -247,7 +247,8 @@ class Client extends EventEmitter {
|
|||||||
async sendMessage(chatId, content, options={}) {
|
async sendMessage(chatId, content, options={}) {
|
||||||
let internalOptions = {
|
let internalOptions = {
|
||||||
caption: options.caption,
|
caption: options.caption,
|
||||||
quotedMessageId: options.quotedMessageId
|
quotedMessageId: options.quotedMessageId,
|
||||||
|
mentionedJidList: Array.isArray(options.mentions) ? options.mentions.map(contact => contact.id._serialized) : []
|
||||||
};
|
};
|
||||||
|
|
||||||
if(content instanceof MessageMedia) {
|
if(content instanceof MessageMedia) {
|
||||||
|
|||||||
@@ -20,6 +20,12 @@ class Contact extends Base {
|
|||||||
*/
|
*/
|
||||||
this.id = data.id;
|
this.id = data.id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contact's phone number
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
this.number = data.userid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if the contact is a business contact
|
* Indicates if the contact is a business contact
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ exports.LoadUtils = () => {
|
|||||||
delete options.quotedMessageId;
|
delete options.quotedMessageId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
options.mentionedJidList = options.mentionedJidList.map(cId=> window.Store.Contact.get(cId).id);
|
||||||
|
|
||||||
let locationOptions = {};
|
let locationOptions = {};
|
||||||
if (options.location) {
|
if (options.location) {
|
||||||
locationOptions = {
|
locationOptions = {
|
||||||
@@ -145,6 +147,7 @@ exports.LoadUtils = () => {
|
|||||||
res.isGroup = contact.isGroup;
|
res.isGroup = contact.isGroup;
|
||||||
res.isWAContact = contact.isWAContact;
|
res.isWAContact = contact.isWAContact;
|
||||||
res.isMyContact = contact.isMyContact;
|
res.isMyContact = contact.isMyContact;
|
||||||
|
res.userid = contact.userid;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user