# Group Lookup & Reply Workflow ## Finding a Group by Member Names When you only know member names (e.g. "丁鹏 延墨 小火子 火星人") but not the wxid: 1. **Query `chatroom` table for `displayname`**, not `rcontact.nickname`: - Small groups (unsaved) have empty `rcontact.nickname` - `chatroom.displayname` auto-generates from member nicknames (e.g. "丁鹏 万界、小火子、火星人、延墨...") - `chatroom.memberlist` contains semicolon-separated member wxids ```sql SELECT chatroomname, memberlist, displayname FROM chatroom WHERE chatroomname LIKE '%@chatroom'; ``` 2. **For larger groups** with custom names, `rcontact.nickname` is populated. Search there instead. 3. **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: ```bash 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\n` prefix to strip - WAL may not reflect latest writes ## Verifying Sent Messages After `send_text_via_hook()`: ```python result = send_text_via_hook('57100316212@chatroom', 'message') # → {'status': 'sent', 'verified': False, ...} ``` - `verified=False` is 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 ```bash 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_prefs` for `last_login_uin` to determine active account - `send_text_via_hook` sends from the **currently active** account, not necessarily the one whose DB you're reading - Cross-check: sent messages appear as `isSend=1` in the active account's DB