Skip to content

WeiLink

PyPI PyPI pre-release GitHub Release License: MIT

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 semanticslogin() / send() / recv()
  • Automatic state managementcontext_token and cursor handled internally
  • Credential persistence — Token saved after QR login
  • Quoted message parsingMessage.ref_msg exposes referenced messages in user replies
  • Unified CLI — Single weilink command with admin, mcp, and openapi subcommands
  • 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