Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

PR: 添加音乐卡片消息支持
功能概述
本 PR 为 Yogurt 添加了音乐卡片消息发送功能,支持发送 QQ音乐、网易云音乐、酷狗音乐等平台的音乐卡片,以及自定义音乐卡片。
实现方式
1. 外部签名服务
由于音乐卡片消息需要特定格式的 Ark JSON,本实现采用了外部签名服务来生成 Ark 消息体:
https://ss.xingzhige.com/music_card/card签名服务接收音乐类型和相关参数,返回可直接发送的 Ark JSON。
2. 新增文件
yogurt/src/commonMain/kotlin/org/ntqqrev/yogurt/music/MusicSegment.kt包含以下类:
MusicType- 音乐平台枚举 (qq/163/kugou/migu/kuwo/custom)MusicSegment/MusicData- 音乐消息段数据结构MusicSignRequest- 签名请求数据类MusicSignResponse- 签名响应数据类MusicSignException- 签名异常类MusicSigner- 签名器,负责调用外部签名服务yogurt/src/commonMain/kotlin/org/ntqqrev/yogurt/api/message/SendMusicMessage.kt新增两个 HTTP API 端点:
POST /api/send_group_music- 发送群聊音乐卡片POST /api/send_private_music- 发送私聊音乐卡片3. API 使用方式
平台音乐 (qq/163/kugou/migu/kuwo)
自定义音乐卡片
4. 为什么不使用 Milky 的 OutgoingSegment?
Milky 协议的
OutgoingSegment是 sealed class,无法在外部扩展添加新的消息类型。因此选择了添加独立的 HTTP API 端点来实现音乐卡片功能,而不是作为消息段类型。测试结果
配置
可在
config.json中配置签名服务地址(可选):{ "musicSignUrl": "https://ss.xingzhige.com/music_card/card" }如不配置,默认使用上述地址。
相关参考
https://ss.xingzhige.com/music_card/card