Skip to main content

WeChat channel plugin for OpenClaw (Python port of @tencent-weixin/openclaw-weixin)

Project description

wechat-clawbot

Python SDK for the WeChat ClawBot ilink API, with a built-in Claude Code Channel bridge.

Ported from @tencent-weixin/openclaw-weixin (TypeScript).

WeChat (iOS) --> ClawBot --> ilink API --> [wechat-clawbot] --> Claude Code Session
                                                  |
Claude Code  <-- MCP Channel Protocol  <--  wechat_reply tool

Features

  • Full ilink API client — getUpdates long-poll, sendMessage, getConfig, sendTyping
  • Multi-account support — QR code login, credential storage, account index
  • Media pipeline — AES-128-ECB encrypted CDN upload/download, image/video/file/voice
  • SILK transcoding — voice message to WAV conversion (optional)
  • Message processing — inbound conversion, slash commands, debug mode, error notices
  • Claude Code Channel — MCP server bridging WeChat messages into Claude Code sessions
  • Async-first — built on httpx + asyncio with shared connection pools

Requirements

  • Python 3.10+
  • uv (recommended) or pip

Installation

uv add wechat-clawbot

Or with pip:

pip install wechat-clawbot

Optional extras:

uv add "wechat-clawbot[silk]"    # SILK voice transcoding
uv add "wechat-clawbot[socks]"   # SOCKS proxy support (e.g. behind a SOCKS5 proxy)

Quick Start — Claude Code Channel

1. Login with WeChat QR code

wechat-clawbot-cc setup

Scan the terminal QR code with WeChat. Credentials are saved to ~/.claude/channels/wechat/account.json.

2. Register the MCP server

claude mcp add wechat -- wechat-clawbot-cc serve

3. Start Claude Code with the WeChat channel

claude --channels server:wechat

Send a message in WeChat ClawBot, and Claude will reply.

Quick Start — Python SDK

import asyncio
from wechat_clawbot.api.client import WeixinApiOptions, get_updates, send_message
from wechat_clawbot.api.types import (
    MessageType, MessageState, MessageItemType,
    SendMessageReq, WeixinMessage, MessageItem, TextItem,
)

async def main():
    opts = WeixinApiOptions(base_url="https://ilinkai.weixin.qq.com", token="your-bot-token")

    # Long-poll for messages
    resp = await get_updates(base_url=opts.base_url, token=opts.token)
    for msg in resp.msgs or []:
        print(f"From: {msg.from_user_id}, Text: {msg.item_list}")

    # Send a reply
    await send_message(opts, SendMessageReq(msg=WeixinMessage(
        to_user_id="user@im.wechat",
        client_id="my-client-id",
        message_type=MessageType.BOT,
        message_state=MessageState.FINISH,
        item_list=[MessageItem(type=MessageItemType.TEXT, text_item=TextItem(text="Hello!"))],
        context_token="token-from-getupdates",
    )))

asyncio.run(main())

Project Structure

src/wechat_clawbot/
  api/              # ilink HTTP API client and protocol types
  auth/             # QR login, account storage, pairing
  cdn/              # AES-128-ECB crypto, CDN upload/download
  config/           # Pydantic configuration schema
  media/            # Media download, MIME types, SILK transcoding
  messaging/        # Inbound conversion, send, slash commands, process pipeline
  monitor/          # Long-poll monitor loop
  storage/          # State directory, sync buffer persistence
  util/             # Logger, ID generation, redaction
  claude_channel/   # Claude Code MCP Channel bridge (CLI + server)

Development

git clone https://github.com/anthropics/wechat-clawbot.git
cd wechat-clawbot
uv sync

# Run tests
uv run pytest tests/ -v

# Lint
uv run ruff check src/ tests/

# Format
uv run ruff format src/ tests/

API Documentation

See docs/api.md for the full public API reference.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wechat_clawbot-0.1.0.tar.gz (36.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wechat_clawbot-0.1.0-py3-none-any.whl (53.8 kB view details)

Uploaded Python 3

File details

Details for the file wechat_clawbot-0.1.0.tar.gz.

File metadata

  • Download URL: wechat_clawbot-0.1.0.tar.gz
  • Upload date:
  • Size: 36.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for wechat_clawbot-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7b4542e63b662c52634822eca8d3c451e17989231c6fc3b75cca46d442d7aa97
MD5 9a92598b6ab63dd26acc74465e616082
BLAKE2b-256 298862f72d422fd96732c56a2a1e9eca2a0ccbf6a8c5e334890612a25b453328

See more details on using hashes here.

Provenance

The following attestation bundles were made for wechat_clawbot-0.1.0.tar.gz:

Publisher: publish.yml on nightsailer/wechat-clawbot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file wechat_clawbot-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: wechat_clawbot-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 53.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for wechat_clawbot-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8dc2a9db4109e019ccb281487c9dbe9ad4272867a6d4cda679f5d2e90b95a0a4
MD5 d6120b5dc38a367dec080ae9f0245809
BLAKE2b-256 9a312308f96a0e10d6560793f3bba73511988afc3b9a78377a626af90e49c28f

See more details on using hashes here.

Provenance

The following attestation bundles were made for wechat_clawbot-0.1.0-py3-none-any.whl:

Publisher: publish.yml on nightsailer/wechat-clawbot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page