From 3f7dfa1190e5d90ed753630c4819e6d103d0618e Mon Sep 17 00:00:00 2001 From: Changhua Date: Wed, 30 Apr 2025 00:23:49 +0800 Subject: [PATCH] feat: bump to v39.5.2 --- README.MD | 11 +++++++---- WeChatFerry/spy/spy.rc | 4 ++-- clients/python/README.MD | 6 +++--- clients/python/wcferry/client.py | 34 +++++++++++++++++++++++++------- 4 files changed, 39 insertions(+), 16 deletions(-) diff --git a/README.MD b/README.MD index eb4cdc0..25aa748 100644 --- a/README.MD +++ b/README.MD @@ -9,7 +9,7 @@ -|[📖 Python 文档](https://wechatferry.readthedocs.io/)|[📺 Python 视频教程](https://mp.weixin.qq.com/s/APdjGyZ2hllXxyG_sNCfXQ)|[🙋 FAQ](https://mp.weixin.qq.com/s/OF8Hyxrkp8JGuVdRK8nyFA)| +|[📖 Python 文档](https://wechatferry.readthedocs.io/)|[📺 Python 视频教程](https://mp.weixin.qq.com/s/APdjGyZ2hllXxyG_sNCfXQ)|[🙋 FAQ](https://mp.weixin.qq.com/s/c2JggTBlOP8fP9j-MlMAvg)| |:-:|:-:|:-:| 👉 [WeChatRobot🤖](https://github.com/lich0821/WeChatRobot),一个基于 WeChatFerry 的 Python 机器人示例。 @@ -207,9 +207,8 @@ WeChatFerry ## 版本更新 -### v39.5.1 -* 修复邀请进群偶发失败 -* 修复获取 wxid 失败 +### v39.5.2 +* 没有新功能
点击查看更多 @@ -221,6 +220,10 @@ WeChatFerry * `y` 是 `WeChatFerry` 的版本,从 0 开始 * `z` 是各客户端的版本,从 0 开始 +### v39.5.1 +* 修复邀请进群偶发失败 +* 修复获取 wxid 失败 + ### v39.5.0 * 适配 `3.9.12.51`。 diff --git a/WeChatFerry/spy/spy.rc b/WeChatFerry/spy/spy.rc index 74bbb1d..346545c 100644 --- a/WeChatFerry/spy/spy.rc +++ b/WeChatFerry/spy/spy.rc @@ -51,7 +51,7 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 39,5,1,0 + FILEVERSION 39,5,2,0 PRODUCTVERSION 3,9,12,51 FILEFLAGSMASK 0x3fL #ifdef _DEBUG @@ -69,7 +69,7 @@ BEGIN BEGIN VALUE "CompanyName", "WeChatFerry" VALUE "FileDescription", "WeChatFerry" - VALUE "FileVersion", "39.5.1.0" + VALUE "FileVersion", "39.5.2.0" VALUE "InternalName", "spy.dll" VALUE "LegalCopyright", "Copyright (C) 2023" VALUE "OriginalFilename", "spy.dll" diff --git a/clients/python/README.MD b/clients/python/README.MD index 78681de..258d184 100644 --- a/clients/python/README.MD +++ b/clients/python/README.MD @@ -1,7 +1,7 @@ # WeChatFerry Python 客户端 [![PyPi](https://img.shields.io/pypi/v/wcferry.svg)](https://pypi.python.org/pypi/wcferry) [![Downloads](https://static.pepy.tech/badge/wcferry)](https://pypi.python.org/pypi/wcferry) [![Documentation Status](https://readthedocs.org/projects/wechatferry/badge/?version=latest)](https://wechatferry.readthedocs.io/zh/latest/?badge=latest) -|[📖 Python 文档](https://wechatferry.readthedocs.io/)|[📺 Python 视频教程](https://mp.weixin.qq.com/s/APdjGyZ2hllXxyG_sNCfXQ)|[🙋 FAQ](https://mp.weixin.qq.com/s/woR71GfODIOBkkj6SQUKQg)| +|[📖 Python 文档](https://wechatferry.readthedocs.io/)|[📺 Python 视频教程](https://mp.weixin.qq.com/s/APdjGyZ2hllXxyG_sNCfXQ)|[🙋 FAQ](https://mp.weixin.qq.com/s/c2JggTBlOP8fP9j-MlMAvg)| |:-:|:-:|:-:| 🤖示例机器人框架:[WeChatRobot](https://github.com/lich0821/WeChatRobot)。 @@ -44,8 +44,8 @@ python -m grpc_tools.protoc --python_out=. --proto_path=../../../WeChatFerry/rpc ## 版本更新 -### v39.5.1.0 -* Bug 修复。 +### v39.5.2.0 +* 没有新功能
点击查看更多 diff --git a/clients/python/wcferry/client.py b/clients/python/wcferry/client.py index 01e2ebc..71675ae 100644 --- a/clients/python/wcferry/client.py +++ b/clients/python/wcferry/client.py @@ -1,11 +1,13 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- -__version__ = "39.5.1.0" +__version__ = "39.5.2.0" import atexit import base64 import ctypes +import ctypes.wintypes +import gc import logging import mimetypes import os @@ -80,10 +82,7 @@ class Wcf(): if host is None: self._local_mode = True self.host = "127.0.0.1" - self.sdk = ctypes.cdll.LoadLibrary(f"{self._wcf_root}/sdk.dll") - if self.sdk.WxInitSDK(debug, port) != 0: - self.LOG.error("初始化失败!") - os._exit(-1) + self._sdk_init(debug, port) self.cmd_url = f"tcp://{self.host}:{self.port}" @@ -125,6 +124,27 @@ class Wcf(): except subprocess.CalledProcessError as e: self.LOG.error(f"修改控制台代码页失败: {e}") + def _sdk_init(self, debug, port): + sdk = ctypes.cdll.LoadLibrary(f"{self._wcf_root}/sdk.dll") + if sdk.WxInitSDK(debug, port) != 0: + self.LOG.error("初始化失败!") + os._exit(-1) + + # 主动卸载 + ctypes.windll.kernel32.FreeLibrary.argtypes = [ctypes.wintypes.HMODULE] + ctypes.windll.kernel32.FreeLibrary(sdk._handle) + del sdk # 删除 Python 对象、触发垃圾回收 + gc.collect() + + def _sdk_destroy(self): + sdk = ctypes.cdll.LoadLibrary(f"{self._wcf_root}/sdk.dll") + sdk.WxDestroySDK() + # 主动卸载 + ctypes.windll.kernel32.FreeLibrary.argtypes = [ctypes.wintypes.HMODULE] + ctypes.windll.kernel32.FreeLibrary(sdk._handle) + del sdk # 删除 Python 对象、触发垃圾回收 + gc.collect() + def cleanup(self) -> None: """关闭连接,回收资源""" if not self._is_running: @@ -139,7 +159,7 @@ class Wcf(): self.cmd_socket.close() self.msg_socket.close() - if self._local_mode and self.sdk and self.sdk.WxDestroySDK() != 0: + if self._local_mode and self.sdk and self._sdk_destroy() != 0: self.LOG.error("退出失败!") self._is_running = False @@ -669,7 +689,7 @@ class Wcf(): if (cnt["wxid"].endswith("@chatroom") or # 群聊 cnt["wxid"].startswith("gh_") or # 公众号 cnt["wxid"] in not_friends.keys() # 其他杂号 - ): + ): continue friends.append(cnt)