diff --git a/README.md b/README.md
index e06eacd..3d7f449 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
NtChat
-
+
diff --git a/fastapi_example/main.py b/fastapi_example/main.py
index 54e7697..5bcff80 100644
--- a/fastapi_example/main.py
+++ b/fastapi_example/main.py
@@ -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()
diff --git a/fastapi_example/models.py b/fastapi_example/models.py
index e1f1e30..1028c51 100644
--- a/fastapi_example/models.py
+++ b/fastapi_example/models.py
@@ -87,6 +87,10 @@ class GetRoomMembersReqModel(ClientReqModel):
room_wxid: str
+class GetRoomNameReqModel(ClientReqModel):
+ room_wxid: str
+
+
class CreateRoomReqModel(ClientReqModel):
member_list: List[str]
diff --git a/ntchat/conf/__init__.py b/ntchat/conf/__init__.py
index fc256b7..1e3ba15 100644
--- a/ntchat/conf/__init__.py
+++ b/ntchat/conf/__init__.py
@@ -1,4 +1,4 @@
-VERSION = '0.1.15'
+VERSION = '0.1.16'
LOG_LEVEL = "DEBUG"
LOG_KEY = 'NTCHAT_LOG'
diff --git a/ntchat/core/mgr.py b/ntchat/core/mgr.py
index 4a7a943..baacf1e 100644
--- a/ntchat/core/mgr.py
+++ b/ntchat/core/mgr.py
@@ -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)
diff --git a/ntchat/core/wechat.py b/ntchat/core/wechat.py
index 5c618d0..49df2c2 100644
--- a/ntchat/core/wechat.py
+++ b/ntchat/core/wechat.py
@@ -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 ''
diff --git a/ntchat/exception/__init__.py b/ntchat/exception/__init__.py
index 1f65fd6..c15f237 100644
--- a/ntchat/exception/__init__.py
+++ b/ntchat/exception/__init__.py
@@ -8,3 +8,7 @@ class WeChatBindError(Exception):
class WeChatNotLoginError(Exception):
pass
+
+
+class WeChatRuntimeError(Exception):
+ pass
diff --git a/ntchat/utils/xdg.py b/ntchat/utils/xdg.py
index 7825678..d0836a7 100644
--- a/ntchat/utils/xdg.py
+++ b/ntchat/utils/xdg.py
@@ -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
+
diff --git a/ntchat/wc/__init__.py b/ntchat/wc/__init__.py
index e69de29..3f6d525 100644
--- a/ntchat/wc/__init__.py
+++ b/ntchat/wc/__init__.py
@@ -0,0 +1,3 @@
+SUPPORT_VERSIONS = [
+ '3.6.0.18'
+]
diff --git a/setup.py b/setup.py
index 9547166..10a6b87 100644
--- a/setup.py
+++ b/setup.py
@@ -194,7 +194,7 @@ extension.extra_compile_cpp_args = extra_compile_cpp_args[target_os]
setup(
name='ntchat',
- version='0.1.15',
+ version='0.1.16',
description='About Conversational RPA SDK for Chatbot Makers',
long_description="",
long_description_content_type='text/markdown',