Add support for @ users in sms

This commit is contained in:
elishadavidi 2026-06-02 10:06:29 +03:00
parent 952d13a74c
commit 6dfa4a8b24
2 changed files with 15 additions and 2 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ node_modules/
.wwebjs_cache/
*.session
.idea/
deploy.ps1

View File

@ -251,9 +251,21 @@ async function startClient() {
? config.ownName
: (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 (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);
} catch (err) {
log('ERROR', `Message handler: ${err.message}`);