@manybot/manybot 5.9.0 → 5.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1680,15 +1680,26 @@ function buildAdminApi(contract, store, chatJid) {
1680
1680
  const botJid = me.id ? normalizeJid(jidNormalizedUser(me.id)) : null;
1681
1681
  const botLid = me.lid ? normalizeJid(me.lid) : null;
1682
1682
  /**
1683
- * Resolve admin-supplied identifiers (bare phone number, @c.us,
1684
- * @s.whatsapp.net, or @lid) to the exact jid WhatsApp has on file for
1685
- * that participant *in this group*. A naive toWireJid() guess is only
1686
- * correct for pn-addressed groups — lid-addressed groups (increasingly
1687
- * common, e.g. when a member hides their phone number) only recognize
1688
- * that member by @lid, which a phone number typed by the admin can't
1689
- * produce on its own. Baileys' raw groupMetadata() participants carry
1690
- * `id` (whatever WA addresses them as here), `jid` (its best
1691
- * phone-number guess) and `lid` — check all three.
1683
+ * Resolve admin-supplied identifiers (bare phone number, bare LID,
1684
+ * @c.us, @s.whatsapp.net, or @lid) to the exact jid WhatsApp has on
1685
+ * file for that participant *in this group*. A naive toWireJid() guess
1686
+ * is only correct for pn-addressed groups — lid-addressed groups
1687
+ * (increasingly common, e.g. when a member hides their phone number)
1688
+ * only recognize that member by @lid, which a phone number typed by
1689
+ * the admin can't produce on its own. Baileys' raw groupMetadata()
1690
+ * participants carry `id` (whatever WA addresses them as here), `jid`
1691
+ * (its best phone-number guess) and `lid` — check all three.
1692
+ *
1693
+ * When the identifier has no explicit domain (the admin typed a bare
1694
+ * number), we don't know if it's a PN or a LID — toWireJid() would
1695
+ * silently guess PN, which never matches a participant that's only
1696
+ * addressable by @lid even when the digits are identical (e.g. typed
1697
+ * "118077710708981", the actual member is "118077710708981@lid"). In
1698
+ * that case, compare by digits alone against id/jid/lid instead of
1699
+ * forcing a domain. When the identifier *does* carry an explicit
1700
+ * domain (@c.us, @s.whatsapp.net, @lid), the domain is meaningful
1701
+ * (disambiguates a PN from a same-digit LID) and the original
1702
+ * wire/resolved comparison is used as before.
1692
1703
  *
1693
1704
  * Throws per-identifier if it doesn't match a current member, instead
1694
1705
  * of silently sending a guessed jid that WhatsApp rejects deep inside
@@ -1698,14 +1709,23 @@ function buildAdminApi(contract, store, chatJid) {
1698
1709
  const meta = await getGroupMetadataCached(contract, groupJid);
1699
1710
  const out = [];
1700
1711
  for (const id of identifiers) {
1712
+ const hasExplicitDomain = /@(s\.whatsapp\.net|lid|g\.us|c\.us)$/.test(id.trim());
1701
1713
  const wire = toWireJid(id);
1702
1714
  const resolved = normalizeJid(store.resolveJid(id));
1715
+ const idDigits = id.replace(/\D/g, "");
1703
1716
  const match = meta.participants.find((p) => {
1704
1717
  const pAny = p;
1705
- return (toWireJid(pAny.id) === wire ||
1706
- normalizeJid(store.resolveJid(pAny.id)) === resolved ||
1707
- (pAny.jid ? toWireJid(pAny.jid) === wire : false) ||
1708
- (pAny.lid ? toWireJid(pAny.lid) === wire : false));
1718
+ if (hasExplicitDomain) {
1719
+ return (toWireJid(pAny.id) === wire ||
1720
+ normalizeJid(store.resolveJid(pAny.id)) === resolved ||
1721
+ (pAny.jid ? toWireJid(pAny.jid) === wire : false) ||
1722
+ (pAny.lid ? toWireJid(pAny.lid) === wire : false));
1723
+ }
1724
+ // Bare number, no domain hint: match by digits against id/jid/lid,
1725
+ // instead of assuming a PN domain that may not be the one WhatsApp
1726
+ // actually uses for this participant (see PN-vs-LID note above).
1727
+ const cands = [pAny.id, pAny.jid, pAny.lid].filter((v) => !!v);
1728
+ return idDigits.length > 0 && cands.some((c) => c.replace(/\D/g, "") === idDigits);
1709
1729
  });
1710
1730
  if (!match) {
1711
1731
  throw new Error(t("driver.groupParticipantNotFound", { id, group: groupJid }));
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "name": "SyntaxError!",
6
6
  "email": "me@stxerr.dev"
7
7
  },
8
- "version": "5.9.0",
8
+ "version": "5.9.1",
9
9
  "license": "GPL-3.0-only",
10
10
  "private": false,
11
11
  "engines": {