Sign inSign up

oaklight/weilink

By oaklight

•Updated 7 months ago

Zero-dependency Python SDK for WeChat bots (iLink): text, image, video and MCP server.

Image
0

10K+

oaklight/weilink repository overview

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 — Three core methods: login() / send() / recv()
  • Automatic state management — context_token and sync cursor handled internally
  • Credential persistence — Token saved after QR login, survives restarts
  • Typing indicator — Support for "typing..." status
  • Unified CLI — Single weilink command with admin and mcp subcommands
  • Web admin panel — Optional browser UI for session management, QR login, and Docker deployment
  • MCP server — Optional MCP⁠ integration for AI agents with stdio/SSE/streamable-http transports (pip install weilink[mcp])

⁠Install

pip install weilink

⁠Quick Start

from weilink import WeiLink

wl = WeiLink()
wl.login()

# Receive messages
messages = wl.recv()
for msg in messages:
    print(f"{msg.from_user}: {msg.text}")

# Reply
wl.send(msg.from_user, "Got it!")

wl.close()

⁠How It Works

WeiLink wraps the WeChat iLink Bot protocol (the underlying protocol of the ClawBot plugin), exposing a message-queue-style interface:

login()  →  QR scan to obtain credentials (persisted)
recv()   →  Long-poll for messages (35s timeout)
send()   →  Reply to a user (context_token auto-attached)
⁠Important Limitations
  • Cannot initiate conversations — User must message the bot first
  • 24-hour window — Messages from the bot are discarded if the user hasn't sent anything in 24 hours
  • Service may be terminated — Tencent can discontinue the iLink API at any time

⁠Admin Panel

A built-in web UI for session management, QR login, and status monitoring:

pip install weilink[server]
weilink admin -p 8080
Dashboard
Dashboard
User Details
User Details
Message History
Message History
QR Login
QR Login

⁠API

MethodDescription
login(force=False)QR code login, reuses existing credentials
recv(timeout=35.0)Long-poll for incoming messages
send(to, text, *, image, voice, file, video, file_name)Send text and/or media (image/voice/file/video), returns bool
download(msg)Download media from a received message
send_typing(to)Show "typing" indicator
stop_typing(to)Cancel "typing" indicator
close()Save state and clean up
is_connectedWhether logged in (property)
bot_idCurrent bot ID (property)

⁠Protocol References

⁠Acknowledgments

⁠Community

Feel free to discuss the project via GitHub Issues⁠ or the LINUX DO⁠ community.

⁠License

MIT⁠

Tag summary

Content type

Image

Digest

sha256:b19d29180…

Size

17.6 MB

Last updated

7 months ago

docker pull oaklight/weilink