diff --git a/run.py b/run.py index fe50869..0fdb27f 100644 --- a/run.py +++ b/run.py @@ -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() diff --git a/services/biz_service.py b/services/biz_service.py index 591a4f1..fe628dc 100644 --- a/services/biz_service.py +++ b/services/biz_service.py @@ -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}') diff --git a/services/gewe_service.py b/services/gewe_service.py index 47227e3..1fd698b 100644 --- a/services/gewe_service.py +++ b/services/gewe_service.py @@ -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,