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.5.tar.gz (26.4 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.5-py3-none-any.whl (31.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for wechat_bridge-2026.4.5.tar.gz
Algorithm Hash digest
SHA256 21a75f57bfbbedf0c8a5ea1d8beab9a110ee510245885181795dc331ababf428
MD5 b78f1b52271ac65bad6de1413a0bdef7
BLAKE2b-256 8ba01ea5fa99a76f20cf6eb9cdcc399c281353307114ea5ea1ff4ba0c6b69ed4

See more details on using hashes here.

Provenance

The following attestation bundles were made for wechat_bridge-2026.4.5.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.5-py3-none-any.whl.

File metadata

File hashes

Hashes for wechat_bridge-2026.4.5-py3-none-any.whl
Algorithm Hash digest
SHA256 c950693179b2c7061f7ee987f0b1aa699e0f38f0e607528565496db5070d9b56
MD5 f40099c836094cee01f20f140c3839ed
BLAKE2b-256 345f13413bce2b19eef645a3172e06af8af77c70f3dce17383a2a99947e66070

See more details on using hashes here.

Provenance

The following attestation bundles were made for wechat_bridge-2026.4.5-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