cyanray / mirai-cpp

本项目为 mirai-api-http 的 C++ 封装,方便使用 C++ 开发基于 mirai-api-http 插件。
GNU Affero General Public License v3.0
148 stars 38 forks source link

发送语音消息时VoiceMessage::length_未初始化导致mirai-api-http可能返回400 #121

Closed Numendacil closed 2 years ago

Numendacil commented 2 years ago

当不使用UploadVoice而是直接填入Url/Path/Id属性发送语音时,由于length_变量未设置初始值将随机取值。虽然mirai-api-http那边的文档说不看length属性,但好像有概率length的上限超过了那边能接收的最大值从而返回 {"code": 400, “msg": "无效参数"}

验证方式:查看发送失败的请求内容为 { "sessionKey": "xxxx" "target": "xxxx" "messageChain": [{ "base64": "" "length": 16582373882432544079 "path": "path/to/amr" "type": "Voice" "url": "" "voiceId": "" }] } 此时mirai-api-http返回{"code":400, "msg":"无效参数"} 把length属性改为较小值,例如 { "sessionKey": "xxxx" "target": "xxxx" "messageChain": [{ "base64": "" "length": 100 "path": "path/to/amr" "type": "Voice" "url": "" "voiceId": "" }] } 则可以成功发送,返回{"code":0,"msg":"success","messageId":402}

mirai版本: 2.8.0-M1 mirai-http-api版本: 2.3.1