|
|
@@ -1368,6 +1368,18 @@ async def handle_add_friend_notice_async(request: Request,token_id,app_id, wxid, |
|
|
|
if ret==200: |
|
|
|
logger.info('自动添加好友成功') |
|
|
|
|
|
|
|
# 保存好友信息 |
|
|
|
await request.app.state.gewe_service.save_contacts_brief_to_cache_async(token_id,app_id, wxid,[to_contact_wxid]) |
|
|
|
|
|
|
|
|
|
|
|
# 判断是否开启了 |
|
|
|
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_text_async.__name__} 不回复消息") |
|
|
|
return |
|
|
|
|
|
|
|
# 好友发送的文字 |
|
|
|
hash_key = f'__AI_OPS_WX__:MESSAGES:{wxid}:{to_contact_wxid}' |
|
|
|
prompt={"role": "user", "content": [{"type": "text","text": msg_content}]} |
|
|
@@ -1382,8 +1394,7 @@ async def handle_add_friend_notice_async(request: Request,token_id,app_id, wxid, |
|
|
|
res=await gpt_client_async(request,messages_to_send,wxid,callback_to_user) |
|
|
|
reply_content=remove_markdown_symbol(res["choices"][0]["message"]["content"]) |
|
|
|
|
|
|
|
#保存好友信息 |
|
|
|
await request.app.state.gewe_service.save_contacts_brief_to_cache_async(token_id,app_id, wxid,[to_contact_wxid]) |
|
|
|
|
|
|
|
|
|
|
|
if reply_content == '不回复': |
|
|
|
logger.warning(f"加好友消息,AI回答<不回复>,跳过微信加好友打招呼消息回复") |
|
|
|