Adapt python client
This commit is contained in:
parent
b55741e7a8
commit
a9e31cf65a
18
clients/python/wcferry/client.py
vendored
18
clients/python/wcferry/client.py
vendored
@ -1,10 +1,11 @@
|
|||||||
#! /usr/bin/env python3
|
#! /usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
__version__ = "39.0.14.1"
|
__version__ = "39.1.0.0"
|
||||||
|
|
||||||
import atexit
|
import atexit
|
||||||
import base64
|
import base64
|
||||||
|
import ctypes
|
||||||
import logging
|
import logging
|
||||||
import mimetypes
|
import mimetypes
|
||||||
import os
|
import os
|
||||||
@ -72,11 +73,12 @@ class Wcf():
|
|||||||
self.LOG.info(f"wcferry version: {__version__}")
|
self.LOG.info(f"wcferry version: {__version__}")
|
||||||
self.port = port
|
self.port = port
|
||||||
self.host = host
|
self.host = host
|
||||||
|
self.sdk = None
|
||||||
if host is None:
|
if host is None:
|
||||||
self._local_mode = True
|
self._local_mode = True
|
||||||
self.host = "127.0.0.1"
|
self.host = "127.0.0.1"
|
||||||
cmd = fr'"{self._wcf_root}\wcf.exe" start {self.port} {"debug" if debug else ""}'
|
self.sdk = ctypes.cdll.LoadLibrary(f"{self._wcf_root}/sdk.dll")
|
||||||
if os.system(cmd) != 0:
|
if self.sdk.WxInitSDK(debug, port) != 0:
|
||||||
self.LOG.error("初始化失败!")
|
self.LOG.error("初始化失败!")
|
||||||
os._exit(-1)
|
os._exit(-1)
|
||||||
|
|
||||||
@ -121,11 +123,9 @@ class Wcf():
|
|||||||
self.disable_recv_msg()
|
self.disable_recv_msg()
|
||||||
self.cmd_socket.close()
|
self.cmd_socket.close()
|
||||||
|
|
||||||
if self._local_mode:
|
if self._local_mode and self.sdk and self.sdk.WxDestroySDK() != 0:
|
||||||
cmd = fr'"{self._wcf_root}\wcf.exe" stop'
|
self.LOG.error("退出失败!")
|
||||||
if os.system(cmd) != 0:
|
|
||||||
self.LOG.error("退出失败!")
|
|
||||||
return
|
|
||||||
self._is_running = False
|
self._is_running = False
|
||||||
|
|
||||||
def keep_running(self):
|
def keep_running(self):
|
||||||
@ -658,7 +658,7 @@ class Wcf():
|
|||||||
if (cnt["wxid"].endswith("@chatroom") or # 群聊
|
if (cnt["wxid"].endswith("@chatroom") or # 群聊
|
||||||
cnt["wxid"].startswith("gh_") or # 公众号
|
cnt["wxid"].startswith("gh_") or # 公众号
|
||||||
cnt["wxid"] in not_friends.keys() # 其他杂号
|
cnt["wxid"] in not_friends.keys() # 其他杂号
|
||||||
):
|
):
|
||||||
continue
|
continue
|
||||||
friends.append(cnt)
|
friends.append(cnt)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user