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), synced with upstream v2.1.1.

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

Features

  • Full ilink API client — getUpdates long-poll, sendMessage, getConfig, sendTyping, with iLink-App-Id / iLink-App-ClientVersion protocol headers
  • Multi-account support — QR code login with IDC redirect, credential storage, stale account cleanup
  • Media pipeline — AES-128-ECB encrypted CDN upload/download with full_url direct-URL support, image/video/file/voice
  • Context token persistence — survives process restarts, disk-backed with change detection
  • 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
  • Secure logging — automatic redaction of sensitive fields (tokens, authorization) in log output
  • Async-first — built on httpx + anyio 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/nightsailer/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/

Documentation

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.3.0.tar.gz (42.0 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.3.0-py3-none-any.whl (59.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: wechat_clawbot-0.3.0.tar.gz
  • Upload date:
  • Size: 42.0 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.3.0.tar.gz
Algorithm Hash digest
SHA256 6ac19b1eee52c1bf199d7de6cb2166c3fa2e896a3f95889cc0cb227f82d4212b
MD5 503b849e24613cfc5c6f301e5b3e031e
BLAKE2b-256 16e73b8ac278be66ccdb3151a0af2868a91b71b56de558e1e8a024df394972b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for wechat_clawbot-0.3.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.3.0-py3-none-any.whl.

File metadata

  • Download URL: wechat_clawbot-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 59.3 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ffcc6d99229accbaf2ba5ca11423358ef280b3ceae94277ac76ea4db4996bbd5
MD5 121a0b2026529f7e8a257804ac67db9d
BLAKE2b-256 94645cc9183289c655f826bbc5e90ed54bf00910e6b89d1b4e14394ae202968f

See more details on using hashes here.

Provenance

The following attestation bundles were made for wechat_clawbot-0.3.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