AI Personal Learning
and practical guidance
Beanbag Marscode1

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.

WeChatFerry: Currently integrating the more fully featured wechat bot development framework-1


 

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 wcferryIf 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.slnThe
    • Click on "Generate" > "Generate Solution", and after compiling the solution, you can find it in the WeChatFerry\WeChatFerry\Out directory to generate sdk.dllThe
    • take note of: If you encounter protoc Error 9009, check Python environment or configuration protoc environment variable (requires protobuf to be installed).

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) # initialization, default port 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("Hello", "wxid_xxxx") # wxid_xxxx is the target WeChat ID
    
    • Support @ someone:wcf.send_text("Hello @Tom", "roomid_xxxx")The
  • receive a message::
    wcf.enable_receiving_msgs() # enable receiving
    while True: msg = wcf.get_msg()
    msg = wcf.get_msg()
    if msg.
    print(f "Received: {msg.content}")
    wcf.disable_receiving_msgs() # stop receiving
    

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: wcf.enable_receiving_msgs()
    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

  1. Launch Framework: Compilation sdk.dllIf you are running a Python script, it is loaded and initialized.
  2. Log in to WeChat: Implementation wcf.get_login_qrcode() Get the QR code and scan it to log in.
  3. Configuration Features: Write scripts to implement message listening, auto-reply or group management.
  4. operational test: Run the script at the command line to check that the microsoft behavior is as expected.
  5. Debugging Optimization: If something goes wrong, you can add a debug log in VS2019 (e.g. DbgMsg("Test")), positioning issues.

Multi-language client support

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.
CDN1
May not be reproduced without permission:Chief AI Sharing Circle " WeChatFerry: A Fully Functional Framework for WeChat Robot Development

Chief AI Sharing Circle

Chief AI Sharing Circle specializes in AI learning, providing comprehensive AI learning content, AI tools and hands-on guidance. Our goal is to help users master AI technology and explore the unlimited potential of AI together through high-quality content and practical experience sharing. Whether you are an AI beginner or a senior expert, this is the ideal place for you to gain knowledge, improve your skills and realize innovation.

Contact Us
en_USEnglish