alvin-bot 4.8.3 โ 4.8.4
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.
- package/CHANGELOG.md +40 -0
- package/dist/platforms/whatsapp.js +31 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,46 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to Alvin Bot are documented here.
|
|
4
4
|
|
|
5
|
+
## [4.8.4] โ 2026-04-11
|
|
6
|
+
|
|
7
|
+
### ๐ WhatsApp self-chat detection for the new `@lid` identity format
|
|
8
|
+
|
|
9
|
+
Ali reported that the WhatsApp bot wasn't responding to "Hi" in his self-chat even after enabling both `Self-chat only` and `Reply to private messages` in the Web UI. Debug logging showed the bot receiving the message correctly and detecting `fromMe=true`, but then hitting the "skip: own message in group/DM" branch because `isSelfChat()` was returning `false`.
|
|
10
|
+
|
|
11
|
+
**Root cause**: WhatsApp has rolled out a new privacy feature that replaces phone-number JIDs in self-chats (and some groups) with a **LID โ Linked Identity**. Instead of `4917661236656@s.whatsapp.net`, messages in a self-chat now arrive with `jid = "162805718225143@lid"` โ a completely opaque identifier that looks nothing like the phone number.
|
|
12
|
+
|
|
13
|
+
Our `isSelfChat(jid)` compared the incoming JID against `sock.user.id` (the traditional phone-number format `4917661236656:22@s.whatsapp.net`), stripped the device suffix, and compared the bare numbers. But the LID has a completely different number (`162805718225143`), so the match failed and every self-chat message fell through to the "own message in DM" skip branch.
|
|
14
|
+
|
|
15
|
+
**Fix**: `isSelfChat()` now checks **both** identity formats:
|
|
16
|
+
|
|
17
|
+
- **Traditional phone JID** via `sock.user.id` (legacy path, still matches on older WhatsApp clients)
|
|
18
|
+
- **LID** via `sock.user.lid` (baileys โฅ 6.7 exposes this) with `@lid` suffix matching
|
|
19
|
+
|
|
20
|
+
Either match wins. The check short-circuits on groups (`@g.us`) so the new code never misclassifies a group as self-chat.
|
|
21
|
+
|
|
22
|
+
Caught on the Mac mini production bot after midnight โ WhatsApp connected, QR scanned, user sending "Hi", bot silent. Debug logging revealed the actual incoming JID (`162805718225143@lid`) which immediately pointed at the LID format as the culprit.
|
|
23
|
+
|
|
24
|
+
### ๐งน Dual-bot session collision (root cause of WhatsApp reconnect flapping)
|
|
25
|
+
|
|
26
|
+
While debugging the `@lid` issue above, the test revealed a deeper problem: two `node dist/index.js` processes were running simultaneously on the Mac mini (PID 47744 from an earlier `launchctl kickstart` that didn't cleanly kill the old instance, plus PID 49153 from a new `launchd install`). Both processes were trying to hold the same WhatsApp Multi-Device session at the same time, causing:
|
|
27
|
+
|
|
28
|
+
- WhatsApp `Reconnecting in 3s` every few seconds (each process would claim the session, the other would be kicked)
|
|
29
|
+
- Baileys `Closing session` dumps to the log
|
|
30
|
+
- Signal session state corruption โ "Warte auf diese Nachricht" (waiting-to-decrypt) messages appearing spontaneously in the self-chat
|
|
31
|
+
|
|
32
|
+
**Short-term workaround**: explicit `pkill -9 -f 'node.*alvin-bot/dist/index'` before `launchctl kickstart` to ensure only one process is running.
|
|
33
|
+
|
|
34
|
+
**Session wipe procedure** (when the corruption is already baked in):
|
|
35
|
+
|
|
36
|
+
1. `launchctl unload -w ~/Library/LaunchAgents/com.alvinbot.app.plist`
|
|
37
|
+
2. `pkill -9 -f "node.*alvin-bot/dist/index"`
|
|
38
|
+
3. `rm -rf ~/.alvin-bot/data/whatsapp-auth`
|
|
39
|
+
4. Remove the zombie linked-device from your phone (iPhone Settings โ Linked Devices โ remove all "Alvin Bot" entries)
|
|
40
|
+
5. `launchctl load -w ~/Library/LaunchAgents/com.alvinbot.app.plist`
|
|
41
|
+
6. Re-scan the QR code
|
|
42
|
+
|
|
43
|
+
A future release should add a proper `alvin-bot wa reset` command to automate this and a startup check that refuses to boot if another instance is already running.
|
|
44
|
+
|
|
5
45
|
## [4.8.3] โ 2026-04-11
|
|
6
46
|
|
|
7
47
|
### ๐ Critical: Claude SDK heartbeat false-positive "unavailable"
|
|
@@ -536,10 +536,38 @@ export class WhatsAppAdapter {
|
|
|
536
536
|
await this.handler(incoming);
|
|
537
537
|
}
|
|
538
538
|
isSelfChat(jid) {
|
|
539
|
-
|
|
540
|
-
if (!myJid)
|
|
539
|
+
if (!this.sock?.user)
|
|
541
540
|
return false;
|
|
542
|
-
|
|
541
|
+
// Groups are never self-chat regardless of which identity format
|
|
542
|
+
// the group uses.
|
|
543
|
+
if (jid.endsWith("@g.us"))
|
|
544
|
+
return false;
|
|
545
|
+
// WhatsApp has two identity formats that can appear in self-chat:
|
|
546
|
+
// 1. Traditional phone-number JID: 49176...:22@s.whatsapp.net
|
|
547
|
+
// 2. LID (linked identity): 162805718...@lid โ privacy feature
|
|
548
|
+
// added in 2024 that hides the real phone number in self-chats
|
|
549
|
+
// and some groups. Baileys exposes this as sock.user.lid.
|
|
550
|
+
//
|
|
551
|
+
// Check both so self-chat detection works regardless of which
|
|
552
|
+
// format WhatsApp chose to tag the chat with today.
|
|
553
|
+
const user = this.sock.user;
|
|
554
|
+
const myId = user.id;
|
|
555
|
+
const myLid = user.lid;
|
|
556
|
+
// Match against phone-number JID (traditional path)
|
|
557
|
+
if (myId) {
|
|
558
|
+
const myNumber = jidToNumber(myId);
|
|
559
|
+
const jidNumber = jidToNumber(jid);
|
|
560
|
+
if (myNumber && jidNumber && myNumber === jidNumber)
|
|
561
|
+
return true;
|
|
562
|
+
}
|
|
563
|
+
// Match against LID (new privacy format)
|
|
564
|
+
if (myLid && jid.endsWith("@lid")) {
|
|
565
|
+
const myLidNum = jidToNumber(myLid);
|
|
566
|
+
const jidLidNum = jidToNumber(jid);
|
|
567
|
+
if (myLidNum && jidLidNum && myLidNum === jidLidNum)
|
|
568
|
+
return true;
|
|
569
|
+
}
|
|
570
|
+
return false;
|
|
543
571
|
}
|
|
544
572
|
// โโ Public API: Groups โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
545
573
|
async getGroups() {
|