Independent WeChatFerry fork with a verified VS2022 build path and an OpenAI-compatible WeChat bot example backed by PostgreSQL.
This fork is based on the last usable source snapshot before the upstream master branch was cleared. It keeps the original project structure, fixes the VS2022 build flow, and adds a production-oriented Python bot entry point.
- Supported Windows WeChat version:
3.9.12.51 - Verified native build toolchain: Visual Studio 2022
- Verified native outputs:
SDK.dll,spy.dll - Local repo path:
D:\workspace\WeChatFerry - Python bot entry point:
clients/python/openai_bot.py
The runtime version check is enforced in WeChatFerry/spy/spy.h and WeChatFerry/spy/spy.cpp.
cd WeChatFerry
build_vs2022.cmd ReleaseAfter a successful build, the native files are copied to:
WeChatFerry\Outclients\python\wcferry
docker compose up -d postgresThis repository now includes a dedicated local PostgreSQL service on host port 5437. The initial schema is created from db/init/001_init.sql and contains chat_sessions and chat_messages.
Useful database commands:
db_up.bat
db_reset.bat
python db_smoke.pyCopy .env.example to .env in the repository root and fill in:
DATABASE_URLOPENAI_API_KEYOPENAI_BASE_URLOPENAI_MODEL
For the existing ephone-compatible setup used in other local projects, the working values are:
OPENAI_BASE_URL=https://api.ephone.chat/v1OPENAI_MODEL=gemini-3.1-pro-preview
For database-only verification:
start_bot.bat dbFor the WeChat bot path:
start_bot.bat wechatThe start script supports two modes:
db: installs dependencies and runsdb_smoke.pywechat: installs dependencies, checksSDK.dllandspy.dll, and runs the Python bot
If venv creation fails on the local Python runtime, the script automatically falls back to a local .deps directory for dependencies.
- Private chat: every text message is sent to the AI service
- Group chat: only messages that
@the bot are sent to the AI service - Only AI conversations are stored in PostgreSQL
- Conversation history is keyed by:
- private chat:
sender - group chat:
roomid
- private chat:
- Model protocol: OpenAI-compatible
chat.completions - Default model:
gpt-5-mini
The repository now includes a dedicated local schema bootstrap for PostgreSQL:
chat_sessionschat_messages
The intended session keying is:
- private chat:
private:{sender} - group chat:
group:{roomid}
This round prepares storage and environment only. The WeChat client integration path is intentionally left unchanged for now.
The OpenAI-compatible bot code now reads and writes against these two tables instead of the earlier single-table prototype.
Each row in chat_messages.metadata now uses a structured JSON shape with:
schema_versionsourcetransportmessagesessionwechatllm- optional
extra
- Minimal upstream example:
clients/python/test.py - Local simple demo:
clients/python/bot_demo.py - OpenAI-compatible bot:
clients/python/openai_bot.py - Main client wrapper:
clients/python/wcferry/client.py
- This project targets Windows desktop WeChat, not the official public platform API.
- The local machine must have a compatible WeChat installed.
- First run may show the disclaimer confirmation dialog.
- If your installed WeChat version is not
3.9.12.51, startup will fail with a version mismatch dialog. - If native files are missing, run
WeChatFerry\build_vs2022.cmd Releasefirst.
- Fork repository: https://github.com/wukangcheng2944/WeChatFerry
- Upstream source project: https://github.com/lich0821/WeChatFerry
Read the project disclaimer before use:
WeChatFerry/DISCLAIMER.md