From f02d95331a6a7675a6ef0b202c147ab607fc26b7 Mon Sep 17 00:00:00 2001 From: devlikepro Date: Sat, 10 Jan 2026 12:28:14 +0700 Subject: [PATCH] [core] ChatWoot - support @lid mention directly fix #1767 closes devlikeapro/waha-plus#36 --- .../chatwoot/messages/to/whatsapp/mentions.test.ts | 8 ++++++++ src/apps/chatwoot/messages/to/whatsapp/mentions.ts | 13 ++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/apps/chatwoot/messages/to/whatsapp/mentions.test.ts b/src/apps/chatwoot/messages/to/whatsapp/mentions.test.ts index 229fdbdc..1cd27cf1 100644 --- a/src/apps/chatwoot/messages/to/whatsapp/mentions.test.ts +++ b/src/apps/chatwoot/messages/to/whatsapp/mentions.test.ts @@ -104,4 +104,12 @@ describe('parseMentionsFromText', () => { mentions: ['1231234@c.us', '5555555@c.us'], }); }); + + it('parses @lid mentions without c.us suffix', () => { + const input = 'Notify @123123@lid now'; + expect(parseMentionsFromText(input)).toEqual({ + text: 'Notify @123123@lid now', + mentions: ['123123@lid'], + }); + }); }); diff --git a/src/apps/chatwoot/messages/to/whatsapp/mentions.ts b/src/apps/chatwoot/messages/to/whatsapp/mentions.ts index 3f1dc764..5090565a 100644 --- a/src/apps/chatwoot/messages/to/whatsapp/mentions.ts +++ b/src/apps/chatwoot/messages/to/whatsapp/mentions.ts @@ -30,10 +30,21 @@ export function parseMentionsFromText(text: string): ParsedMentions { content = content.replace(allRegexReplace, '$1').trim(); } + const lidRegex = /(^|\s)@(\d{6,15})@lid\b/g; + const lidMatches = text.matchAll(lidRegex); + + for (const match of lidMatches) { + const lidNumber = match[2]; + const formattedLid = `${lidNumber}@lid`; + if (!mentions.includes(formattedLid)) { + mentions.push(formattedLid); + } + } + // Regex to match @ followed by phone number // Matches: @558591203123, @5585991203123, etc. // Phone numbers: 7-15 digits (international format) - const phoneRegex = /(^|\s)@(\d{7,15})\b/g; + const phoneRegex = /(^|\s)@(\d{7,15})(?!@lid)\b/g; const phoneMatches = text.matchAll(phoneRegex); for (const match of phoneMatches) {