From a74aa12641b7c100983cbe2174df6e9ee089accd Mon Sep 17 00:00:00 2001 From: befantasy <31535803+befantasy@users.noreply.github.com> Date: Fri, 15 Sep 2023 18:37:05 +0800 Subject: [PATCH] Update wechat_channel.py --- channel/wechat/wechat_channel.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/channel/wechat/wechat_channel.py b/channel/wechat/wechat_channel.py index 061440a..b8c1ac6 100644 --- a/channel/wechat/wechat_channel.py +++ b/channel/wechat/wechat_channel.py @@ -212,3 +212,20 @@ class WechatChannel(ChatChannel): file_storage = reply.content itchat.send_file(file_storage, toUserName=receiver) logger.info("[WX] sendFile, receiver={}".format(receiver)) + elif reply.type == ReplyType.VIDEO: # 新增视频回复类型 + video_storage = reply.content + itchat.send_video(video_storage, toUserName=receiver) + logger.info("[WX] sendFile, receiver={}".format(receiver)) + elif reply.type == ReplyType.VIDEO_URL: # 新增视频URL回复类型 + video_url = reply.content + logger.debug(f"[WX] start download video, video_url={video_url}") + video_res = requests.get(video_url, stream=True) + video_storage = io.BytesIO() + size = 0 + for block in video_res.iter_content(1024): + size += len(block) + video_storage.write(block) + logger.info(f"[WX] download video success, size={size}, video_url={video_url}") + video_storage.seek(0) + itchat.send_video(video_storage, toUserName=receiver) + logger.info("[WX] sendVideo url={}, receiver={}".format(video_url, receiver))