Ver código fonte

商机代理名义发送

develop
H Vs 18 horas atrás
pai
commit
ee7f32e0a7
1 arquivos alterados com 39 adições e 2 exclusões
  1. +39
    -2
      services/biz_service.py

+ 39
- 2
services/biz_service.py Ver arquivo

@@ -84,6 +84,8 @@ class BizService():
await self.sns_sendvideo_forward_handler_async(content_data)
case 'sns-sendvideo':
await self.sns_sendvideo_handler_async(content_data)
case 'biz-assistant-sending':
await self.biz_assistant_sending_handler_async(content_data)
case _:
logger.warning(f'kakfa 未处理息类型 {msg_type_data}')

@@ -166,8 +168,6 @@ class BizService():
elif wx_content["type"] == "file":
await self.send_file_message(token_id, app_id, agent_wxid, [intersection_wxid], wx_content.get("file_url", {}).get("url"))


async def send_text_message_async(self, token_id, app_id, agent_wxid, intersection_wxids, text):
for t in intersection_wxids:
# 发送文本消息
@@ -537,4 +537,41 @@ class BizService():
logger.warning(f'{wxid} 用户创建不够三天,不能使用该功能')
return None
return loginfo

async def biz_assistant_sending_handler_async(self,content_data):
logger.info(f'商机代理发送 {content_data}')
wxids = [c['wxid'] for c in content_data.get("contact_list", [])]
wx_content_list = content_data.get("wx_content", [])
if not wxids:
logger.warning(f'wxids 空列表不处理 {wxids}')
return
if wx_content_list is None or len(wx_content_list) == 0:
logger.warning(f'wx_content_list 空列表不处理 {wx_content_list}')
return
biz_assistant_wxid="wxid_9pocbage7cdb22"
k, loginfo = await self.wxchat.get_login_info_by_wxid_async(biz_assistant_wxid)
if not loginfo:
logger.warning(f'{biz_assistant_wxid} 助理信信息不存在')
return None
login_status = loginfo.get('status', '0')
if login_status != '1':
logger.warning(f'{biz_assistant_wxid} 助理已经离线')
return None
if not loginfo:
return
app_id=loginfo.get('appId','')
token_id=loginfo.get('tokenId','')

for wxid in wxids:
for wx_content in wx_content_list:
if wx_content["type"] == "text":
await self.send_text_message_async(token_id, app_id, biz_assistant_wxid, [wxid], wx_content["text"])
elif wx_content["type"] == "image_url":
await self.send_image_messagae_sync(token_id, app_id, biz_assistant_wxid, [wxid], wx_content.get("image_url", {}).get("url"))
elif wx_content["type"] == "tts":
await self.send_tts_message(token_id, app_id, biz_assistant_wxid, [wxid], wx_content["text"])
elif wx_content["type"] == "file":
await self.send_file_message(token_id, app_id, biz_assistant_wxid, [wxid], wx_content.get("file_url", {}).get("url"))

Carregando…
Cancelar
Salvar