Skip to main content

WeChat <-> Claude Code bridge via iLink Bot API

Project description

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

快速开始

1. 获取 iLink Bot 凭证

通过微信 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

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_bridge-2026.4.11.2.tar.gz (39.6 kB view details)

Uploaded Source

Built Distribution

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

wechat_bridge-2026.4.11.2-py3-none-any.whl (44.7 kB view details)

Uploaded Python 3

File details

Details for the file wechat_bridge-2026.4.11.2.tar.gz.

File metadata

  • Download URL: wechat_bridge-2026.4.11.2.tar.gz
  • Upload date:
  • Size: 39.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for wechat_bridge-2026.4.11.2.tar.gz
Algorithm Hash digest
SHA256 db905832a534fd74d67d18f6cf2b029f1c4444e9a408970c56de64a64148ca71
MD5 a774528733268f14b4057d0c2ae14cbe
BLAKE2b-256 f7496a0a772d8d6f479e5c45992e2c7f5612fc5403b0b051d6a17cd4aa3529e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for wechat_bridge-2026.4.11.2.tar.gz:

Publisher: publish.yml on feir/wechat-bridge

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_bridge-2026.4.11.2-py3-none-any.whl.

File metadata

File hashes

Hashes for wechat_bridge-2026.4.11.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f97ca7e543fbc1859cc02eea948f104cff71c938101208d60f65d2e769fe4628
MD5 04be993b84aa178c7f7c031078e0d5e3
BLAKE2b-256 33e2621d86e87131a1de89063de89fbcdfc3e92ce55f0c41e5b3ce203c780496

See more details on using hashes here.

Provenance

The following attestation bundles were made for wechat_bridge-2026.4.11.2-py3-none-any.whl:

Publisher: publish.yml on feir/wechat-bridge

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