WeChatFerry

repository·master·Indexed 27 days ago

https://github.com/lich0821/wechatferry

A framework for automating WeChat interactions with multiple client implementations. Includes WcfAuto (Python), WeChatFerry-go and go_wcf_http (Go), WCF-BMC and wcferry (Java/Spring Boot), and Wrest Chat (Go). Supports message receiving, sending media, group/contact management, and integration with LLMs via HTTP, Websocket, and Nanomsg protocols.

Tokens
8.4K
Snippets
18
Records
79
Agent score
92%

What's inside WeChatFerry

  1. Overview of Wrest Chat (wechat-rest)

    master

    Wrest Chat is a general-purpose intelligent chat assistant that communicates with chat software (currently adapted for PC WeChat) via the Nanomsg protocol. It provides a web management interface and supports integration with various Large Language Models (LLMs) such as GPT, Gemini, Xinghuo, Wenxin, Hunyuan, and Tongyi Qianwen.

    Note: This specific package (wechat-rest) provides only HTTP and Websocket interface capabilities to maintain client purity. For full functional implementation, refer to the wrest-chat project.

    Key Features:

    • Written in Go with no runtime dependencies.
    • HTTP Interfaces: Easy integration with various programming languages.
    • Websocket Interfaces: Real-time reception of pushed new messages.
    • Authorization: Supports HTTP/WS interface authorization.
    • Extensibility: Supports scheduled tasks, external commands, and command plugins (via wrest-plugin).
    • Data Handling: Converts XML messages into Objects to facilitate frontend parsing.
  2. Available client implementations for WeChatFerry

    master

    WeChatFerry provides various client implementations across different programming languages and protocols:

    • HTTP: go_wcf_http, wrest-chat, wcf-http
    • Java: java client
    • NodeJS: wcferry-node, node-wcferry, wechatferry
    • C#: WeChatFerry.Net (via NuGet), WeChatFerry-CSharp
    • Rust: wcfrust, wechat-bot
    • Docker: docker_wechat, wechatbot-provider-windows
  3. Setup WCF-BMC (Spring Boot + Maven Client)

    master

    WCF-BMC is a Spring Boot and Maven-based client for WeChatFerry. Note: This project only supports Windows.

    Prerequisites

    • JDK: 1.8+
    • Maven: 3.8+
    • WeChat Client: 3.9.12.51
    • WeChatFerry-SDK: 39.5.2
    • MySQL: 8.0+ (Optional/Backup)

    Installation Steps

    1. Download Files: Get the latest release from the official releases page.
    2. Open Project: Open the project in your IDE using WeChatFerry/clients/java/wcf-bmc as the root directory.
    3. Add Maven: Right-click the pom.xml file in WeChatFerry/clients/java/wcf-bmc/pom.xml and add it to Maven to download dependencies.
    4. Replace DLLs: Extract the downloaded release files and replace the contents of the clients/java/wcf-bmc/dll directory. The required files are:
      • sdk.dll
      • spy.dll
      • spy_debug.dll
      • DISCLAIMER.md Note: If you cannot replace the files, ensure the WeChat client is completely closed.
    5. Configure: Edit src/main/resources/application.yml to point to your DLL location and set the socket port.
  4. Use the WcfAuto client for message handling

    master

    WcfAuto uses a Register object to handle incoming WeChat messages via decorators. You can register synchronous or asynchronous handlers for different event types.

    Event Types

    • Message Registration: Use @receiver.message_register() to handle incoming messages. Use parameters isDivision=True (for division/group messages), isGroup=True, and isPyq=False (to exclude Moments/Pyq).
    • Async Message Registration: Use @receiver.async_message_register() for asynchronous handling.
    • Group Change Registration: Use @receiver.group_changed_register(allow_other_receive=False) to detect changes in group information.
    • Message Revoke Registration: Use @receiver.revoke_message_register(allow_other_receive=False) to detect when a message is revoked. Use msg.get_revoke_msg() to inspect the revoked content.
    • Custom Message Registration: Use @receiver.custom_message_register(register_name='custom', msg_judge_func=judge, allow_other_receive=False) to register a handler that only triggers if a provided msg_judge_func returns True.
    from wcfauto import Register, Wcf, WxMsg
    
    receiver = Register()
    
    @receiver.message_register(isDivision=True, isGroup=True, isPyq=False)
    def process_msg(bot: Wcf, msg: WxMsg):
        # Handle message
        pass
    
    receiver.run()