H Vs 4 semanas atrás
pai
commit
2c5f4ce017
3 arquivos alterados com 13 adições e 12 exclusões
  1. +6
    -6
      run.py
  2. +6
    -6
      services/biz_service.py
  3. +1
    -0
      services/gewe_service.py

+ 6
- 6
run.py Ver arquivo

@@ -26,11 +26,11 @@ def start_celery_beat():

if __name__ == "__main__":
# 启动 FastAPI、Celery Worker 和 Celery Beat
#fastapi_process = start_fastapi()
celery_worker_process = start_celery_worker()
celery_beat_process = start_celery_beat()
fastapi_process = start_fastapi()
#celery_worker_process = start_celery_worker()
#celery_beat_process = start_celery_beat()

# 等待子进程完成
#fastapi_process.wait()
celery_worker_process.wait()
celery_beat_process.wait()
fastapi_process.wait()
#celery_worker_process.wait()
#celery_beat_process.wait()

+ 6
- 6
services/biz_service.py Ver arquivo

@@ -146,7 +146,7 @@ class BizService():
for t in intersection_wxids:
if t == intersection_wxids[0]:
# 发送图片
ret,ret_msg,res = await self.wxchat.post_image(token_id, app_id, t, image_url)
ret,ret_msg,res = await self.wxchat.post_image_async(token_id, app_id, t, image_url)
if ret==200:
aeskey = res["aesKey"]
cdnthumburl = res["fileId"]
@@ -162,11 +162,11 @@ class BizService():
else:
if aeskey !="":
# 转发图片
ret,ret_msg,res = await self.wxchat.forward_image(token_id, app_id, t, aeskey, cdnthumburl, cdnthumblength, cdnthumbheight, cdnthumbwidth, length, md5)
ret,ret_msg,res = await self.wxchat.forward_image_async(token_id, app_id, t, aeskey, cdnthumburl, cdnthumblength, cdnthumbheight, cdnthumbwidth, length, md5)
logger.info(f'{agent_wxid} 向 {t} 转发图片【{image_url}】{ret_msg}')
else:
# 发送图片
ret,ret_msg,res = await self.wxchat.post_image(token_id, app_id, t, image_url)
ret,ret_msg,res = await self.wxchat.post_image_async(token_id, app_id, t, image_url)
if ret==200:
aeskey = res["aesKey"]
cdnthumburl = res["fileId"]
@@ -194,7 +194,7 @@ class BizService():
for t in intersection_wxids:
# 发送送语音消息
if voice_url:
ret,ret_msg,res = await self.wxchat.post_voice(token_id, app_id, t, voice_url,voice_during)
ret,ret_msg,res = await self.wxchat.post_voice_async(token_id, app_id, t, voice_url,voice_during)
if ret==200:
logger.info(f'{agent_wxid} 向 {t} 发送语音文本【{text}】{ret_msg}')
@@ -238,13 +238,13 @@ class BizService():
video_thumb_url,video_duration =download_video_and_get_thumbnail(file_url,thumbnail_path)
print(f'视频缩略图 {video_thumb_url} 时长 {video_duration}')

ret,ret_msg,res = await self.wxchat.post_video(token_id, app_id, t, file_url,video_thumb_url,video_duration)
ret,ret_msg,res = await self.wxchat.post_video_async(token_id, app_id, t, file_url,video_thumb_url,video_duration)
if ret==200:
self.wxchat.forward_video_aeskey = res["aesKey"]
self.wxchat.forward_video_cdnvideourl = res["cdnThumbUrl"]
self.wxchat.forward_video_length = res["length"]
else:
ret,ret_msg,res = await self.wxchat.forward_video(token_id, app_id, t, self.wxchat.forward_video_aeskey, self.wxchat.forward_video_cdnvideourl, self.wxchat.forward_video_length)
ret,ret_msg,res = await self.wxchat.forward_video_async(token_id, app_id, t, self.wxchat.forward_video_aeskey, self.wxchat.forward_video_cdnvideourl, self.wxchat.forward_video_length)
print('转发视频')
if ret==200:
logger.info(f'{agent_wxid} 向 {t} 发送视频【{file_url}】{ret_msg}')


+ 1
- 0
services/gewe_service.py Ver arquivo

@@ -360,6 +360,7 @@ class GeWeService:
return response_object.get('ret', None), response_object.get('msg', None), response_object.get('data', None)
async def forward_image_async(self, token_id, app_id, to_wxid, aeskey, cdnthumburl, cdnthumblength, cdnthumbheight, cdnthumbwidth, length, md5):
api_url = f"{self.base_url}/v2/api/message/forwardImage"
headers = {
'X-GEWE-TOKEN': token_id,


Carregando…
Cancelar
Salvar