From f7f21f34613c0d33e547230382ddd99d8e98af77 Mon Sep 17 00:00:00 2001 From: H Vs Date: Mon, 3 Mar 2025 14:32:28 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=BE=A4=E5=8F=91=E8=A7=86?= =?UTF-8?q?=E9=A2=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/messages_resource.py | 2 +- wechat/biz.py | 8 ++++---- wechat/gewe_chat.py | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/resources/messages_resource.py b/resources/messages_resource.py index 58d0b15..cc1e682 100644 --- a/resources/messages_resource.py +++ b/resources/messages_resource.py @@ -23,7 +23,7 @@ class MessagesResource(Resource): def post(self): msg = request.get_json() - logger.info(f"收到微信回调消息: {msg}") + logger.info(f"收到微信回调消息: {json.dumps(msg, separators=(',', ':'),ensure_ascii=False)}") type_name =msg.get("TypeName") app_id = msg.get("Appid") # token_id = "f828cb3c-1039-489f-b9ae-7494d1778a15" diff --git a/wechat/biz.py b/wechat/biz.py index 92ad90a..8409513 100644 --- a/wechat/biz.py +++ b/wechat/biz.py @@ -242,14 +242,14 @@ def send_video_message(wxchat:gewe_chat.GeWeChatCom, token_id, app_id, agent_wxi filename = os.path.basename(parsed_url.path) tmp_file_path = os.path.join(os.getcwd(),'tmp', filename) # 拼接完整路径 thumbnail_path=tmp_file_path.replace('.mp4','.jpg') - video_thumb_url,video_duration =utils.download_video_and_get_thumbnail(file_url,thumbnail_path) - - print(f'视频缩略图 {video_thumb_url} 时长 {video_duration}') if wxchat.forward_video_aeskey == '': + video_thumb_url,video_duration =utils.download_video_and_get_thumbnail(file_url,thumbnail_path) + print(f'视频缩略图 {video_thumb_url} 时长 {video_duration}') + ret,ret_msg,res = wxchat.post_video(token_id, app_id, t, file_url,video_thumb_url,video_duration) if ret==200: wxchat.forward_video_aeskey = res["aesKey"] - wxchat.forward_video_cdnvideourl = res["cdnVideoUrl"] + wxchat.forward_video_cdnvideourl = res["cdnThumbUrl"] wxchat.forward_video_length = res["length"] else: ret,ret_msg,res = wxchat.forward_video(token_id, app_id, t, wxchat.forward_video_aeskey, wxchat.forward_video_cdnvideourl, wxchat.forward_video_length) diff --git a/wechat/gewe_chat.py b/wechat/gewe_chat.py index e1b8a9d..708abb5 100644 --- a/wechat/gewe_chat.py +++ b/wechat/gewe_chat.py @@ -374,7 +374,7 @@ class GeWeChatCom: "toWxid": to_wxid, "videoUrl": video_url, "videoDuration":video_duration, - "videoThumbUrl":video_thumb_url + "thumbUrl":video_thumb_url } response = requests.post(url=api_url, headers=headers, data=json.dumps(data)) response_object = response.json() @@ -410,7 +410,7 @@ class GeWeChatCom: } response = requests.post(url=api_url, headers=headers, data=json.dumps(data)) response_object = response.json() - return response_object.get('data',None),response_object.get('ret',None),response_object.get('msg',None) + return response_object.get('ret',None),response_object.get('msg',None),response_object.get('data',None) def add_contacts(self,token_id:str,app_id:str,scene:int,option:int,v3:str,v4:str,content:str): api_url = f"{self.base_url}/v2/api/contacts/addContacts"