v39.0.14.0

This commit is contained in:
Changhua 2024-02-18 16:13:16 +08:00
parent 69db15752f
commit 03a29c86c8
3 changed files with 90 additions and 69 deletions

View File

@ -44,9 +44,9 @@ python -m grpc_tools.protoc --python_out=. --proto_path=../../../WeChatFerry/rpc
## 版本更新
### v39.0.12 (2023.12.20)
* 修复一个问题
* 消息转发
### v39.0.14.0 (2024.02.18)
* 若干优化
* 若干功能
<details><summary>点击查看更多</summary>
@ -86,5 +86,7 @@ python -m grpc_tools.protoc --python_out=. --proto_path=../../../WeChatFerry/rpc
* 邀请群成员
* 图片 OCR
* 转发消息
* 撤回消息
* 获取登录二维码
</details>

View File

@ -1,7 +1,7 @@
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
__version__ = "39.0.12.0"
__version__ = "39.0.14.0"
import atexit
import base64
@ -55,13 +55,13 @@ class Wcf():
host (str): `wcferry` RPC 服务器地址默认本地启动也可以指定地址连接远程服务
port (int): `wcferry` RPC 服务器端口默认为 10086接收消息会占用 `port+1` 端口
debug (bool): 是否开启调试模式仅本地启动有效
block (bool): 是否阻塞等待微信登录不阻塞的话可以手动获取登录二维码主动登录
Attributes:
contacts (list): 联系人缓存调用 `get_contacts` 后更新
self_wxid (str): 登录账号 wxid
"""
def __init__(self, host: str = None, port: int = 10086, debug: bool = True) -> None:
def __init__(self, host: str = None, port: int = 10086, debug: bool = True, block: bool = True) -> None:
self._local_mode = False
self._is_running = False
self._is_receiving_msg = False
@ -98,14 +98,15 @@ class Wcf():
self.msg_url = self.cmd_url.replace(str(self.port), str(self.port + 1))
atexit.register(self.cleanup) # 退出的时候停止消息接收,防止资源占用
while not self.is_login(): # 等待微信登录成功
sleep(1)
self._is_running = True
self.contacts = []
self.msgQ = Queue()
self._SQL_TYPES = {1: int, 2: float, 3: lambda x: x.decode("utf-8"), 4: bytes, 5: lambda x: None}
self.self_wxid = self.get_self_wxid()
if block:
self.LOG.info("等待微信登录...")
while not self.is_login(): # 等待微信登录成功
sleep(1)
def __del__(self) -> None:
self.cleanup()
@ -145,6 +146,14 @@ class Wcf():
"""是否已启动接收消息功能"""
return self._is_receiving_msg
def get_qrcode(self) -> str:
"""获取登录二维码,已经登录则返回空字符串"""
req = wcf_pb2.Request()
req.func = wcf_pb2.FUNC_REFRESH_QRCODE # FUNC_REFRESH_QRCODE
rsp = self._send_request(req)
return rsp.str
def is_login(self) -> bool:
"""是否已经登录"""
req = wcf_pb2.Request()

File diff suppressed because one or more lines are too long