wechatbot
English

模块化、可扩展的微信 iLink Bot SDK —— 提供 Node.jsPythonGoRust 四种语言。同时内含 Pi 编程助手扩展,微信扫码即可与 Pi 对话。跨平台:已在 Linux、macOS、Windows 上测试通过。GitHubCI

微信扫码 → 与 Pi 编程助手对话

一键安装

无需编译环境,预编译二进制开箱即用。支持 WindowsmacOSLinux

# macOS / Linux curl -fsSL https://raw.githubusercontent.com/corespeed-io/wechatbot/main/install.sh | bash
# Windows (PowerShell) irm https://raw.githubusercontent.com/corespeed-io/wechatbot/main/install.ps1 | iex
平台支持
平台GoRust
Windows x64
Windows ARM64🔜
macOS x64
macOS ARM64 (Apple Silicon)
Linux x64
Linux ARM64

也可以从 GitHub Releases 直接下载。

快速开始

npm install @wechatbot/wechatbot
import { WeChatBot } from '@wechatbot/wechatbot' const bot = new WeChatBot() await bot.login() // 显示二维码 → 微信扫码 bot.onMessage(async (msg) => { await bot.sendTyping(msg.userId) await bot.reply(msg, `Echo: ${msg.text}`) }) await bot.start()

在微信中扫描二维码 → 机器人上线。凭证自动保存,会话自动恢复。

SDK

选择你的语言。所有 SDK 共享相同的架构和能力。

📡
协议参考
iLink Bot API 规范,含时序图。扫码登录、消息循环、CDN 加密。
🟢
Node.js SDK
TypeScript 优先,统一发送/下载 API,完整媒体支持,69 个测试。零运行时依赖。
🐍
Python SDK
Async/aiohttp,装饰器处理器,dataclass 类型,17 个测试。地道的 Python 风格。
🔵
Go SDK
协程安全,仅标准库,AES-128-ECB 加密,32 个测试。地道的 Go 风格。
🦀
Rust SDK
Async/tokio,serde 类型,thiserror 错误,38 个测试。类型安全,零拷贝。
🤖
Pi Agent
Pi 扩展 —— 微信扫码,与 Pi 对话。支持文本、图片、文件、语音。

架构

所有 SDK 遵循相同的分层设计:

graph TD A["🤖 你的机器人代码"] --> B["Bot 客户端(编排器)"] B --> C["轮询器"] B --> D["发送器"] B --> E["输入状态"] B --> F["媒体"] C --> G["上下文存储(Token 缓存)"] D --> G E --> G F --> G G --> H["协议层 / API(HTTP 调用)"] H --> I["存储(凭证 + 状态)"]

共享能力:二维码登录、长轮询、context_token 管理、AES-128-ECB CDN 加密、会话恢复、智能文本分片。

SDK 对比
Node.jsGo / Rust
中间件✓ Express 风格— (处理器组合)
存储可插拔(文件/内存/自定义)文件存储
事件类型化 EventEmitter回调函数
媒体✓ 上传 + 下载✓ AES 加密
依赖零运行时stdlib / reqwest+serde
测试6932 / 38
平台Linux、macOS、WindowsLinux、macOS、Windows
WeChatBot — 模块化微信 iLink Bot SDK(Node.js)