From 7a5732b09895ca00b8672e7211ca2f1822a73f66 Mon Sep 17 00:00:00 2001 From: "Rayo (via Clawdbot)" Date: Tue, 27 Jan 2026 13:40:02 +0000 Subject: [PATCH] fix: search WhatsApp account subdirs for LID mapping files When jidToE164() is called without opts.authDir (e.g., from extract.ts), the LID reverse mapping lookup fails because it only searches the top-level credentials directory, not the whatsapp// subdirs where the mapping files are actually stored. This causes the reply-to-bot trigger in groups to fail when the bot's JID uses the WhatsApp LID format, as the implicit mention comparison can't resolve the LID to an E164 phone number. Fixes #2771 --- src/utils.ts | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index cdb56c7ee..05488a89b 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -89,7 +89,28 @@ function resolveLidMappingDirs(opts?: JidToE164Options): string[] { addDir(opts?.authDir); for (const dir of opts?.lidMappingDirs ?? []) addDir(dir); addDir(resolveOAuthDir()); - addDir(path.join(CONFIG_DIR, "credentials")); + const credentialsDir = path.join(CONFIG_DIR, "credentials"); + addDir(credentialsDir); + + // Also search WhatsApp account subdirectories for LID mappings + const waDir = path.join(credentialsDir, "whatsapp"); + try { + if (fs.existsSync(waDir) && fs.statSync(waDir).isDirectory()) { + for (const account of fs.readdirSync(waDir)) { + const accountDir = path.join(waDir, account); + try { + if (fs.statSync(accountDir).isDirectory()) { + dirs.add(accountDir); + } + } catch { + // Skip if can't stat + } + } + } + } catch { + // Skip if whatsapp dir doesn't exist or can't be read + } + return [...dirs]; }