Bladeren bron

文字回复白名单

develop
H Vs 8 uur geleden
bovenliggende
commit
7fa1859c0c
2 gewijzigde bestanden met toevoegingen van 7 en 1 verwijderingen
  1. +2
    -0
      app/endpoints/config_endpoint.py
  2. +5
    -1
      app/endpoints/pipeline_endpoint.py

+ 2
- 0
app/endpoints/config_endpoint.py Bestand weergeven

@@ -27,6 +27,7 @@ class SaveConfigRequest(BaseModel):
@config_router.post("/wxchat/getconfig",response_model=None) @config_router.post("/wxchat/getconfig",response_model=None)
#@validate_wxid #@validate_wxid
async def get_config(request: Request, body: GetConfigRequest): async def get_config(request: Request, body: GetConfigRequest):
wxid = body.wxid wxid = body.wxid
if not wxid: if not wxid:
return {"code": 400, "message": "wxid 不能为空"} return {"code": 400, "message": "wxid 不能为空"}
@@ -80,6 +81,7 @@ async def save_config(request: Request, body: SaveConfigRequest):
# 去重 # 去重
validated_config.chatroomIdWhiteList=list(set(validated_config.chatroomIdWhiteList)) validated_config.chatroomIdWhiteList=list(set(validated_config.chatroomIdWhiteList))
validated_config.addContactsFromChatroomIdWhiteList=list(set(validated_config.addContactsFromChatroomIdWhiteList)) validated_config.addContactsFromChatroomIdWhiteList=list(set(validated_config.addContactsFromChatroomIdWhiteList))
validated_config.privateChatWhiteList=list(set(validated_config.privateChatWhiteList))
except ValidationError as e: except ValidationError as e:
return {'code': 407, 'message': e.errors().__str__()} return {'code': 407, 'message': e.errors().__str__()}


+ 5
- 1
app/endpoints/pipeline_endpoint.py Bestand weergeven

@@ -374,7 +374,11 @@ async def handle_text_async(request: Request,token_id,app_id, wxid,msg_data,from
validated_config = AgentConfig.model_validate(config) validated_config = AgentConfig.model_validate(config)


if not validated_config.privateGroupChatEnabled: if not validated_config.privateGroupChatEnabled:
logger.warning(f"微信号 {wxid} 关闭好友和群自动回复功能,{handle_text_async.__name__} 不回复消息")
logger.warning(f"智能体微信号 {wxid} 关闭好友和群自动回复功能,{handle_text_async.__name__} 不回复消息")
return
if wxid != from_wxid and from_wxid not in validated_config.privateChatWhiteList:
logger.warning(f"智能体微信号 {wxid} 的好友 {from_wxid} 不在回复白名单,{handle_text_async.__name__} 不回复消息")
return return
# 判断是否转人工处理功能 # 判断是否转人工处理功能


Laden…
Annuleren
Opslaan