diff --git a/fastapi_example/main.py b/fastapi_example/main.py index a21fc1a..ee143f6 100644 --- a/fastapi_example/main.py +++ b/fastapi_example/main.py @@ -161,6 +161,14 @@ async def add_room_friend(model: models.ModifyRoomNameReqModel): return response_json(1, data) +@app.post("/room/quit_room", summary="退出群", tags=["Room"], + response_model=models.ResponseModel) +@catch_exception() +async def quit_room(model: models.RoomReqModel): + data = client_mgr.get_client(model.guid).quit_room(model.room_wxid) + return response_json(1, data) + + @app.post("/msg/send_text", summary="发送文本消息", tags=["Msg"], response_model=models.ResponseModel) @catch_exception() async def msg_send_text(model: models.SendTextReqModel): diff --git a/fastapi_example/models.py b/fastapi_example/models.py index 83d1425..7db4304 100644 --- a/fastapi_example/models.py +++ b/fastapi_example/models.py @@ -101,8 +101,11 @@ class AddRoomFriendReqModel(ClientReqModel): verify: str -class ModifyRoomNameReqModel(ClientReqModel): +class RoomReqModel(ClientReqModel): room_wxid: str + + +class ModifyRoomNameReqModel(RoomReqModel): name: str diff --git a/ntchat/core/wechat.py b/ntchat/core/wechat.py index 9aef999..8a94790 100644 --- a/ntchat/core/wechat.py +++ b/ntchat/core/wechat.py @@ -349,3 +349,11 @@ class WeChat: } return self.__send_sync(send_type.MT_ADD_FRIEND_MSG, data) + def quit_room(self, room_wxid: str): + """ + 退出群 + """ + data = { + "room_wxid": room_wxid + } + return self.__send(send_type.MT_QUIT_DEL_ROOM_MSG, data)