WeChatFerry: A Fully Functional Framework for WeChat Robot Development
General Introduction
WeChatFerry is an open source WeChat robot underlying framework, created and maintained by developer lich0821 on GitHub. The project through the WeChat Hook technology , provides a set of powerful SDK , allowing developers to WeChat features with a variety of large language model ( such as ChatGPT, Gemini, DeepSeek, ChatGLM, Xunfei Starfire , Tigerbot , etc.) integrated to achieve the automation of tasks and intelligent dialogue . The core module is written in C++, supports multiple client languages (e.g. Python, Rust, Go, Java, Node.js, C#, etc.), and is adapted to specific WeChat versions (currently supporting 3.9.11.25). With its flexibility and rich features, WeChatFerry has attracted 5.5k stars and 1.1k forks, making it a popular tool for WeChat robot development.

Function List
- Send and receive messages: Supports sending text (with @), images, files, GIFs, and can listen to and receive messages.
- Large Language Model Integration: Access to models such as ChatGPT, Gemini, DeepSeek, ChatGLM, Xunfei Starfire, etc. to realize intelligent reply or task processing.
- Group Chat Management: Supports operations such as inviting group members and getting group information.
- multimedia processing: Support for downloading pictures, files, decrypting pictures, and converting voice files (Silk) to MP3.
- database access: You can query WeChat contacts, message records and other data.
- Login Status Management: Provide functions to get login QR code, check login status, get account information (wxid, nickname, cell phone number, etc.).
- Multi-language client: Support for client-side development in Python, Rust, Go, Java, Node.js, C# and other languages.
- Automated tasks: Support message forwarding, timed tasks, etc., for customer service, education and other scenarios.
Using Help
Installation process
The use of WeChatFerry is divided into two parts: core module compilation (for developers) and client-side installation (for normal users). Below are the detailed steps:
1. Client installation (in Python, for example)
- Installing the Python Environment: Python 3.10 is recommended, download and install it from python.org, and make sure that the
pip
Available. - Install the wcferry package: Open the command line and run:
pip install --upgrade wcferry
- Verify Installation: Run in Python
import wcferry
If no error is reported, it is successful.
2. Core module compilation (optional for developers)
- Preparing the environment::
- Install Visual Studio 2019 (Community Edition), which includes C++ development components.
- Install Git for cloning repositories.
- clone warehouse::
git clone https://github.com/lich0821/WeChatFerry.git cd WeChatFerry
- Compiling projects::
- Open with VS2019
WeChatFerry\WeChatFerry\WeChatFerry.sln
The - Click on "Generate" > "Generate Solution", and after compiling the solution, you can find it in the
WeChatFerry\WeChatFerry\Out
directory to generatesdk.dll
The - take note of: If you encounter
protoc
Error 9009, check Python environment or configurationprotoc
environment variable (requires protobuf to be installed).
- Open with VS2019
3. Launch WeChat and inject
- Prepare microsoft: Install a supported version of WeChat (e.g. 3.9.10.27 or 3.9.11.25, see Releases).
- running example: refer to the official code for loading
sdk.dll
and initialized:import ctypes sdk = ctypes.cdll.LoadLibrary("C:/path/to/WeChatFerry/WeChatFerry/Out/sdk.dll") sdk.WxInitSDK(False, 10086) # 初始化,默认端口 10086
- Exiting the SDK: Run it when you're done using it
sdk.WxDestroySDK()
The Python process can be shut down if you want it to be a good one, and if you want it to be a good one.
Main Functions
Send and receive messages
- Send text message::
from wcferry import Wcf wcf = Wcf() wcf.send_text("你好", "wxid_xxxx") # wxid_xxxx 为目标微信 ID
- Support @ someone:
wcf.send_text("你好 @Tom", "roomid_xxxx")
The
- Support @ someone:
- receive a message::
wcf.enable_receiving_msgs() # 开启接收 while True: msg = wcf.get_msg() if msg: print(f"收到: {msg.content}") wcf.disable_receiving_msgs() # 停止接收
Large Language Model Integration
- Access to ChatGPT Example(You need to configure the API Key by yourself):
from wcferry import Wcf import openai wcf = Wcf() openai.api_key = "your_api_key" def chatgpt_reply(msg): response = openai.ChatCompletion.create( model="gpt-3.5-turbo", messages=[{"role": "user", "content": msg.content}] ) wcf.send_text(response.choices[0].message.content, msg.sender) wcf.enable_receiving_msgs() while True: msg = wcf.get_msg() if msg: chatgpt_reply(msg)
multimedia processing
- Send Picture::
wcf.send_image("C:/Pictures/test.jpg", "wxid_xxxx")
- Speech to MP3: Use
smc
module (compilation required), set the.silk
Documentation converted to.mp3
::from wcferry import smc smc.silk_to_mp3("input.silk", "output.mp3")
Group Chat Management
- Invited members::
wcf.invite_room_members("roomid_xxxx", ["wxid_user1", "wxid_user2"])
- Get group information::
room_info = wcf.get_chatroom_info("roomid_xxxx") print(room_info)
Example of operation flow
- Launch Framework: Compilation
sdk.dll
If you are running a Python script, it is loaded and initialized. - Log in to WeChat: Implementation
wcf.get_login_qrcode()
Get the QR code and scan it to log in. - Configuration Features: Write scripts to implement message listening, auto-reply or group management.
- operational test: Run the script at the command line to check that the microsoft behavior is as expected.
- Debugging Optimization: If something goes wrong, you can add a debug log in VS2019 (e.g.
DbgMsg("Test")
), positioning issues.
Multi-language client support
- Rust: Use wcfrustThe
- Go: Reference go_wcf_httpThe
- JavaSee java client descriptionThe
- Node.js: Use wcferry-nodeThe
- C#: Reference WeChatFerry-CSharpThe
- Docker: Use docker_wechatThe
caveat
- The current version of WeChat is 3.9.11.25, which may cause injection failure.
- Projects are for study and research purposes only and follow the MIT license.
- Multi-opening is not supported at this time, and requires a single instance to run.
© Copyright notes
The copyright of the article belongs to the author, please do not reprint without permission.
Related posts
No comments...