group-lookup-and-reply.md
2.39 KB
Group Lookup & Reply Workflow
Finding a Group by Member Names
When you only know member names (e.g. "丁鹏 延墨 小火子 火星人") but not the wxid:
- Query
chatroomtable fordisplayname, notrcontact.nickname:- Small groups (unsaved) have empty
rcontact.nickname chatroom.displaynameauto-generates from member nicknames (e.g. "丁鹏 万界、小火子、火星人、延墨...")chatroom.memberlistcontains semicolon-separated member wxids
- Small groups (unsaved) have empty
SELECT chatroomname, memberlist, displayname
FROM chatroom
WHERE chatroomname LIKE '%@chatroom';
For larger groups with custom names,
rcontact.nicknameis populated. Search there instead.Verified group (2026-07-09):
57100316212@chatroom— "丁鹏 万界、小火子、火星人、延墨..."- Members: dp543831577 (丁鹏), wxid_51ap3m6p9xs722 (小火子), yibooo (火星人), wxid_jh2hzq8ay8tu22 (延墨)
Reading Chatroom Messages
Prefer wechat-viewer API over raw SQLCipher for message reading:
curl -s "http://127.0.0.1:5000/api/messages?talker=57100316212@chatroom&limit=30"
Advantages:
- Content is already parsed (sender prefix stripped, multiline handled)
- JSON output, easy to parse in Python
- No key management needed per query
Raw SQLCipher approach has pitfalls:
- Content format is
sender_wxid:\nactual_content— multiline parsing breaks with|delimiter - Output includes
ok\nprefix to strip - WAL may not reflect latest writes
Verifying Sent Messages
After send_text_via_hook():
result = send_text_via_hook('57100316212@chatroom', 'message')
# → {'status': 'sent', 'verified': False, ...}
verified=Falseis normal — the hook can't always confirm DB write- Verify via API, not raw DB: WAL lag means raw sqlcipher reads may be stale
- API endpoint reflects latest state immediately
curl -s "http://127.0.0.1:5000/api/messages?talker=57100316212@chatroom&limit=3" | \
python3 -c "import sys,json; [print(m['msgId'],m['isSend'],m['text'][:80]) for m in json.load(sys.stdin)['data']]"
Multi-Account Pitfall
When device has multiple WeChat accounts:
- Check
shared_prefsforlast_login_uinto determine active account send_text_via_hooksends from the currently active account, not necessarily the one whose DB you're reading- Cross-check: sent messages appear as
isSend=1in the active account's DB