From 6dfa4a8b2455ba565b4ea29a13fbc1a07a0c72b0 Mon Sep 17 00:00:00 2001 From: elishadavidi <62501723+elishadavidi@users.noreply.github.com> Date: Tue, 2 Jun 2026 10:06:29 +0300 Subject: [PATCH] Add support for @ users in sms --- .gitignore | 3 ++- index.js | 14 +++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 56ecc27..8363364 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ node_modules/ .wwebjs_auth/ .wwebjs_cache/ *.session -.idea/ \ No newline at end of file +.idea/ +deploy.ps1 \ No newline at end of file diff --git a/index.js b/index.js index f05f449..da16663 100644 --- a/index.js +++ b/index.js @@ -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}`);