Add support for @ users in sms
This commit is contained in:
parent
952d13a74c
commit
6dfa4a8b24
3
.gitignore
vendored
3
.gitignore
vendored
@ -3,4 +3,5 @@ node_modules/
|
|||||||
.wwebjs_auth/
|
.wwebjs_auth/
|
||||||
.wwebjs_cache/
|
.wwebjs_cache/
|
||||||
*.session
|
*.session
|
||||||
.idea/
|
.idea/
|
||||||
|
deploy.ps1
|
||||||
14
index.js
14
index.js
@ -251,9 +251,21 @@ async function startClient() {
|
|||||||
? config.ownName
|
? config.ownName
|
||||||
: (contact.name || contact.pushname || contact.shortName || contact.number || 'Unknown');
|
: (contact.name || contact.pushname || contact.shortName || contact.number || 'Unknown');
|
||||||
|
|
||||||
const body = message.body || (message.hasMedia ? '[Media]' : '');
|
let body = message.body || (message.hasMedia ? '[Media]' : '');
|
||||||
if (!body) return;
|
if (!body) return;
|
||||||
|
|
||||||
|
if (message.mentionedIds && message.mentionedIds.length > 0) {
|
||||||
|
for (const id of message.mentionedIds) {
|
||||||
|
const num = id.split('@')[0];
|
||||||
|
if (!body.includes(`@${num}`)) continue;
|
||||||
|
try {
|
||||||
|
const c = await client.getContactById(id);
|
||||||
|
const name = c.name || c.pushname || c.shortName || num;
|
||||||
|
body = body.replaceAll(`@${num}`, `@${name}`);
|
||||||
|
} catch (_) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
enqueue(chat.name, sender, body);
|
enqueue(chat.name, sender, body);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
log('ERROR', `Message handler: ${err.message}`);
|
log('ERROR', `Message handler: ${err.message}`);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user