Multi-Session Echo Bot¶
Demonstrates multi-session support: logs into two WeChat accounts on the same bot and echoes messages from all sessions.
See examples/multi_echo.py in the repository.
Usage¶
You will be prompted to scan a QR code for each session.
How It Works¶
- Creates a single
WeiLinkinstance. - Calls
wl.login(name="...")twice with different session names -- each call triggers a separate QR code login for a different WeChat account. wl.recv()returns messages from all active sessions in one call.- Each message carries a
msg.bot_idfield identifying which session it belongs to.
Key Features Demonstrated¶
- Multi-session login -- calling
wl.login(name=...)multiple times to register different WeChat accounts. - Unified receive -- a single
wl.recv()call aggregates messages across all sessions. - Session identification -- using
msg.bot_idto distinguish which session a message came from. - Session introspection --
wl.sessionsandwl.bot_idslist all active sessions and their bot IDs.