瀏覽代碼

文字回复白名单

develop
H Vs 8 小時之前
父節點
當前提交
7fa1859c0c
共有 2 個文件被更改,包括 7 次插入1 次删除
  1. +2
    -0
      app/endpoints/config_endpoint.py
  2. +5
    -1
      app/endpoints/pipeline_endpoint.py

+ 2
- 0
app/endpoints/config_endpoint.py 查看文件

@@ -27,6 +27,7 @@ class SaveConfigRequest(BaseModel):
@config_router.post("/wxchat/getconfig",response_model=None)
#@validate_wxid
async def get_config(request: Request, body: GetConfigRequest):
wxid = body.wxid
if not 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.addContactsFromChatroomIdWhiteList=list(set(validated_config.addContactsFromChatroomIdWhiteList))
validated_config.privateChatWhiteList=list(set(validated_config.privateChatWhiteList))
except ValidationError as e:
return {'code': 407, 'message': e.errors().__str__()}


+ 5
- 1
app/endpoints/pipeline_endpoint.py 查看文件

@@ -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)

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
# 判断是否转人工处理功能


Loading…
取消
儲存