diff --git a/admin/dashboard/blueprints/contacts.py b/admin/dashboard/blueprints/contacts.py index c05e243..59a8517 100644 --- a/admin/dashboard/blueprints/contacts.py +++ b/admin/dashboard/blueprints/contacts.py @@ -267,7 +267,7 @@ def api_send_message(): return jsonify({'success': False, 'message': '未上传文件'}) file = request.files['file'] client_msg_id, create_time, new_msg_id = loop.run_until_complete( - server.client.send_voice_message(wxid, file.read(), format="MP3") + server.client.send_voice_message(wxid, file.read(), format="mp3") ) return jsonify({ 'success': True, diff --git a/wechat_ipad/client/message.py b/wechat_ipad/client/message.py index afe1624..5b4c013 100644 --- a/wechat_ipad/client/message.py +++ b/wechat_ipad/client/message.py @@ -280,7 +280,7 @@ class MessageMixin(WechatAPIClientBase): else: self.error_handler(json_resp) - async def send_voice_message(self, wxid: str, voice: Union[str, bytes, os.PathLike], format: str = "AMR") -> \ + async def send_voice_message(self, wxid: str, voice: Union[str, bytes, os.PathLike], format: str = "amr") -> \ tuple[int, int, int]: """发送语音消息。 @@ -300,12 +300,12 @@ class MessageMixin(WechatAPIClientBase): """ return await self._queue_message(self._send_voice_message, wxid, voice, format) - async def _send_voice_message(self, wxid: str, voice: Union[str, bytes, os.PathLike], format: str = "AMR") -> \ + async def _send_voice_message(self, wxid: str, voice: Union[str, bytes, os.PathLike], format: str = "mar") -> \ tuple[int, int, int]: if not self.wxid: raise UserLoggedOut("请先登录") - elif format not in ["AMR", "WAVE", "MP3", "SILK", "SPEEX"]: + elif format not in ["amr", "wave", "mp3", "silk", "speex"]: raise ValueError("format must be one of amr, wav, mp3") # read voice to byte