From 6076e2ed0a9c55bf9a4b5d38e72f88860bf11b97 Mon Sep 17 00:00:00 2001 From: lanvent Date: Sun, 2 Apr 2023 12:29:10 +0800 Subject: [PATCH] fix: voice longer than 60s cannot be sent --- channel/wechat/wechaty_channel.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/channel/wechat/wechaty_channel.py b/channel/wechat/wechaty_channel.py index 82c4f01..259ce82 100644 --- a/channel/wechat/wechaty_channel.py +++ b/channel/wechat/wechaty_channel.py @@ -73,6 +73,9 @@ class WechatyChannel(ChatChannel): file_path = reply.content sil_file = os.path.splitext(file_path)[0] + '.sil' voiceLength = int(any_to_sil(file_path, sil_file)) + if voiceLength >= 60000: + voiceLength = 60000 + logger.info('[WX] voice too long, length={}, set to 60s'.format(voiceLength)) # 发送语音 t = int(time.time()) msg = FileBox.from_file(sil_file, name=str(t) + '.sil') @@ -113,7 +116,6 @@ class WechatyChannel(ChatChannel): return logger.debug('[WX] message:{}'.format(cmsg)) room = msg.room() # 获取消息来自的群聊. 如果消息不是来自群聊, 则返回None - isgroup = room is not None ctype = cmsg.ctype context = self._compose_context(ctype, cmsg.content, isgroup=isgroup, msg=cmsg)