WeiLink¶
Lightweight Python SDK for the WeChat iLink Bot protocol.
Features¶
- Zero runtime dependencies — AES media encryption uses OpenSSL via ctypes with pure-Python fallback
- Message queue semantics —
login()/send()/recv() - Automatic state management —
context_tokenand cursor handled internally - Credential persistence — Token saved after QR login
- Quoted message parsing —
Message.ref_msgexposes referenced messages in user replies - Unified CLI — Single
weilinkcommand withadmin,mcp, andopenapisubcommands - Web admin panel — Optional browser UI for session management, QR login, and Docker deployment
- MCP / OpenAPI server — Optional MCP and OpenAPI server for AI agents and REST integrations (
pip install weilink[server]) - Docker ready — Multi-platform container image on Docker Hub (amd64, arm64, armv7)
Quick Start¶
from weilink import WeiLink
wl = WeiLink()
wl.login()
messages = wl.recv()
for msg in messages:
wl.send(msg.from_user, f"Echo: {msg.text}")
wl.close()
Important Limitations¶
- Cannot initiate conversations — user must message first
- 24-hour inactivity window — bot messages discarded after 24h
- Tencent may terminate iLink service at any time
Acknowledgments¶
- Terminal QR code rendering based on nayuki/QR-Code-generator (MIT License)
- AES-128 cipher core derived from bozhu/AES-Python (MIT License), rewritten for Python 3 with ECB mode and PKCS7 padding added