From dcff84d7109e9d02b00dcc77378170602145e8de Mon Sep 17 00:00:00 2001 From: H Vs Date: Fri, 25 Apr 2025 16:18:06 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/endpoints/pipeline_endpoint.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/endpoints/pipeline_endpoint.py b/app/endpoints/pipeline_endpoint.py index ce71e9f..ea868a3 100644 --- a/app/endpoints/pipeline_endpoint.py +++ b/app/endpoints/pipeline_endpoint.py @@ -853,6 +853,12 @@ async def handle_image_async(request: Request,token_id,app_id, wxid,msg_data,fro ''' 私聊图片消息 ''' + config=await request.app.state.gewe_service.get_wxchat_config_from_cache_async(wxid) + validated_config = AgentConfig.model_validate(config) + if not validated_config.privateGroupChatEnabled: + logger.warning(f"微信号 {wxid} 关闭好友和群自动回复功能,{handle_image_async.__name__} 不回复消息") + return + msg_content=msg_data["Content"]["string"] callback_to_user=from_wxid @@ -891,6 +897,12 @@ async def handle_image_group_async(request: Request,token_id,app_id, wxid,msg_da msg_content=msg_data["Content"]["string"] callback_to_user=msg_data["FromUserName"]["string"] + config=await request.app.state.gewe_service.get_wxchat_config_from_cache_async(wxid) + validated_config = AgentConfig.model_validate(config) + if not validated_config.privateGroupChatEnabled: + logger.warning(f"微信号 {wxid} 关闭好友和群自动回复功能,{handle_image_group_async.__name__} 不回复消息") + return + # aeskey = re.search(r'aeskey="([^"]+)"', msg_content).group(1) # cdnthumburl = re.search(r'cdnthumburl="([^"]+)"', msg_content).group(1) # md5 = re.search(r'md5="([^"]+)"', msg_content).group(1) @@ -929,6 +941,13 @@ async def handle_voice_async(request: Request,token_id,app_id, wxid,msg_data,fro msg_content=msg_data["Content"]["string"] msg_id=msg_data["MsgId"] + config=await request.app.state.gewe_service.get_wxchat_config_from_cache_async(wxid) + validated_config = AgentConfig.model_validate(config) + if not validated_config.privateGroupChatEnabled: + logger.warning(f"微信号 {wxid} 关闭好友和群自动回复功能,{handle_voice_async.__name__} 不回复消息") + return + + request.app.state.message_lock[app_id]=asyncio.Lock() config=await request.app.state.gewe_service.get_wxchat_config_from_cache_async(wxid)