Skip to main content

WeChat Bridge

在微信中使用 Claude Code — 通过 iLink Bot API 将微信消息桥接到 Claude Code CLI,支持文本、语音(ASR 转文字)、图片(CDN 下载 + AES 解密 + 视觉理解)。

它能做什么

"帮我分析这段代码的问题"                → Claude Code 读代码、给反馈
[发送一张截图]                         → CDN 下载 → AES 解密 → Claude 视觉分析
[发送一条语音]                         → ASR 转文字 → Claude 理解并回复
"/status"                             → 查看 context 用量、token 费用
"/compact"                            → 压缩上下文,延长会话寿命

核心特性

多模态消息

  • 文本 — 直接发送,Claude Code 处理并回复
  • 语音 — 自动提取微信 ASR 转写文字,无需额外模型
  • 图片 — CDN 下载 + AES-128-ECB 解密 + Claude 视觉理解

Bridge 命令

命令 说明
/new 重置会话(清除上下文,开始新对话)
/stop 停止当前正在运行的任务
/compact 压缩上下文(释放 token 空间)
/status 查看会话状态(context 用量 / 费用 / 模型)
/help 显示帮助

上下文管理

  • 跨消息维持完整上下文,bridge 重启自动恢复会话
  • Context 用量监控(70% / 85% 阈值),自动在回复末尾提示
  • /compact 压缩上下文,/new 重置会话

多用户支持

  • 每用户独立会话与任务队列
  • 主用户 / 访客用户权限分离,访客独立费用上限
  • 多用户工作区隔离(可选)

CLI 工具

wechat-cli 提供消息发送和用户管理命令,可用于通知推送等场景:

wechat-cli send-message --user-id <id> --text "部署完成"
wechat-cli send-message --broadcast --text "系统维护通知"
wechat-cli list-users

快速开始

通过微信 OpenClaw 平台创建 iLink Bot,获取 bot_token 和 base_url。

2. 安装

pipx install wechat-bridge        # 推荐(隔离环境)

# 或从源码
git clone https://github.com/feir/wechat-bridge.git
cd wechat-bridge && pip install -e '.[dev]'

升级

# PyPI 安装
pipx upgrade wechat-bridge

# 源码安装
cd wechat-bridge && git pull
pip install -e '.[dev]'           # 仅依赖变更时需要

3. 认证

python -m wechat_bridge.ilink_auth
# 交互式输入 bot_token 和 base_url
# → 凭证写入 ~/.config/wechat-bridge/credentials.json

4. 配置

创建 .env 文件(参考 .env.example):

WECHAT_ALLOWED_USERS=user_id_1,user_id_2
CLAUDE_MODEL=sonnet
CLAUDE_TIMEOUT=300
WECHAT_MAX_CONCURRENT=3

5. 运行

wechat-bridge

部署

# systemd(Linux)
cp wechat-bridge.service ~/.config/systemd/user/
systemctl --user daemon-reload
systemctl --user enable --now wechat-bridge

开发

pip install -e '.[dev]'
pytest tests/ -v

License

MIT

Metadata

Release files for wechat-bridge 2026.4.11.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wechat-bridge 2026.4.11.2
File Size Uploaded Provenance Actions
wechat_bridge-2026.4.11.2.tar.gz 39.6 kB With provenance Details for wechat_bridge-2026.4.11.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for wechat-bridge 2026.4.11.2
File Interpreter ABI Platform Actions
wechat_bridge-2026.4.11.2-py3-none-any.whl Python 3 none any Details for wechat_bridge-2026.4.11.2-py3-none-any.whl

Total release size: 84.3 kB

Release files / wechat_bridge-2026.4.11.2.tar.gz

Download URL wechat_bridge-2026.4.11.2.tar.gz
Size 39.6 kB
Tags Source
SHA-256 checksum
How to use checksums
db905832a534fd74d67d18f6cf2b029f1c4444e9a408970c56de64a64148ca71
BLAKE2b-256 checksum
How to use checksums
f7496a0a772d8d6f479e5c45992e2c7f5612fc5403b0b051d6a17cd4aa3529e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 11, 2026.

Transparency log

Release files / wechat_bridge-2026.4.11.2-py3-none-any.whl

Download URL wechat_bridge-2026.4.11.2-py3-none-any.whl
Size 44.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f97ca7e543fbc1859cc02eea948f104cff71c938101208d60f65d2e769fe4628
BLAKE2b-256 checksum
How to use checksums
33e2621d86e87131a1de89063de89fbcdfc3e92ce55f0c41e5b3ce203c780496
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 11, 2026.

Transparency log

Security for wechat-bridge 2026.4.11.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for wechat_bridge-2026.4.11.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 11, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page