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)