mirror of
https://github.com/smallevilbeast/ntchat.git
synced 2025-05-23 02:26:11 +08:00
优化异常输出
This commit is contained in:
parent
38506a0e7b
commit
330f0724f3
|
@ -1,6 +1,6 @@
|
|||
<h1 align="center">NtChat</h1>
|
||||
<p align="center">
|
||||
<a href="https://github.com/smallevilbeast/ntchat/releases"><img src="https://img.shields.io/badge/release-0.1.15-blue.svg?" alt="release"></a>
|
||||
<a href="https://github.com/smallevilbeast/ntchat/releases"><img src="https://img.shields.io/badge/release-0.1.16-blue.svg?" alt="release"></a>
|
||||
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-brightgreen.svg?" alt="License"></a>
|
||||
</p>
|
||||
|
||||
|
|
|
@ -114,6 +114,17 @@ async def get_rooms(model: models.ClientReqModel):
|
|||
return response_json(1, data)
|
||||
|
||||
|
||||
@app.post("/room/get_name_name", summary="获取群名称", tags=["Room"],
|
||||
response_model=models.ResponseModel)
|
||||
@catch_exception()
|
||||
async def get_rooms(model: models.GetRoomNameReqModel):
|
||||
name = client_mgr.get_client(model.guid).get_room_name(model.room_wxid)
|
||||
data = {
|
||||
"name": name
|
||||
}
|
||||
return response_json(1, data)
|
||||
|
||||
|
||||
@app.post("/room/get_room_members", summary="获取群成员列表", tags=["Room"],
|
||||
response_model=models.ResponseModel)
|
||||
@catch_exception()
|
||||
|
|
|
@ -87,6 +87,10 @@ class GetRoomMembersReqModel(ClientReqModel):
|
|||
room_wxid: str
|
||||
|
||||
|
||||
class GetRoomNameReqModel(ClientReqModel):
|
||||
room_wxid: str
|
||||
|
||||
|
||||
class CreateRoomReqModel(ClientReqModel):
|
||||
member_list: List[str]
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
VERSION = '0.1.15'
|
||||
VERSION = '0.1.16'
|
||||
|
||||
LOG_LEVEL = "DEBUG"
|
||||
LOG_KEY = 'NTCHAT_LOG'
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import json
|
||||
import os.path
|
||||
from ntchat.wc import wcprobe
|
||||
from ntchat.utils.xdg import get_helper_file
|
||||
from ntchat.exception import WeChatVersionNotMatchError, WeChatBindError
|
||||
from ntchat.wc import wcprobe, SUPPORT_VERSIONS
|
||||
from ntchat.utils.xdg import get_helper_file, is_support_version, has_helper_file
|
||||
from ntchat.exception import WeChatVersionNotMatchError, WeChatBindError, WeChatRuntimeError
|
||||
from ntchat.utils.singleton import Singleton
|
||||
from ntchat.const import notify_type
|
||||
from ntchat.utils.logger import get_logger
|
||||
|
@ -31,9 +31,16 @@ class WeChatMgr(metaclass=Singleton):
|
|||
else:
|
||||
version = wechat_version
|
||||
|
||||
if not is_support_version(version):
|
||||
raise WeChatVersionNotMatchError(f"ntchat support wechat versions: {','.join(SUPPORT_VERSIONS)}")
|
||||
|
||||
if not has_helper_file():
|
||||
raise WeChatRuntimeError('When using pyinstaller to package exe, you need to add the '
|
||||
'`--collect-data=ntchat` parameter')
|
||||
|
||||
helper_file = get_helper_file(version)
|
||||
if not os.path.exists(helper_file):
|
||||
raise WeChatVersionNotMatchError()
|
||||
raise WeChatRuntimeError("missing core files")
|
||||
|
||||
log.info("initialize wechat, version: %s", version)
|
||||
|
||||
|
|
|
@ -479,3 +479,13 @@ class WeChat:
|
|||
"remark": remark
|
||||
}
|
||||
return self.__send_sync(send_type.MT_MODIFY_FRIEND_REMARK, data)
|
||||
|
||||
def get_room_name(self, room_wxid: str) -> str:
|
||||
"""
|
||||
获取群名
|
||||
"""
|
||||
sql = f"select nickname from contact where username='{room_wxid}'"
|
||||
result = self.sql_query(sql, 1)["result"]
|
||||
if result:
|
||||
return result[0][0]
|
||||
return ''
|
||||
|
|
|
@ -8,3 +8,7 @@ class WeChatBindError(Exception):
|
|||
|
||||
class WeChatNotLoginError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class WeChatRuntimeError(Exception):
|
||||
pass
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import os
|
||||
import sys
|
||||
import os.path
|
||||
from ntchat.wc import SUPPORT_VERSIONS
|
||||
|
||||
|
||||
def get_exec_dir():
|
||||
|
@ -26,9 +27,13 @@ def get_helper_file(version):
|
|||
return os.path.join(get_wc_dir(), f"helper_{version}.dat")
|
||||
|
||||
|
||||
def get_support_download_url():
|
||||
return 'https://webcdn.m.qq.com/spcmgr/download/WeChat3.6.0.18.exe'
|
||||
def has_helper_file():
|
||||
for name in os.listdir(get_wc_dir()):
|
||||
if name.startswith("helper_"):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(get_helper_file('3.6.0.18'))
|
||||
def is_support_version(version):
|
||||
return version in SUPPORT_VERSIONS
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
SUPPORT_VERSIONS = [
|
||||
'3.6.0.18'
|
||||
]
|
Loading…
Reference in New Issue
Block a user