feat: bump to v39.5.2

This commit is contained in:
Changhua
2025-04-30 00:23:49 +08:00
parent 36e1bbddd9
commit 3f7dfa1190
4 changed files with 39 additions and 16 deletions
+27 -7
View File
@@ -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)