Conversation
added 3 commits
December 23, 2025 13:02
Author
|
🤔 |
Collaborator
|
发送自定义音乐卡片的现状是需要签名,并且签名过程高度依赖安卓协议 + 技术细节并非广为人知,所以和 LGR 的签名一样是通过公共 HTTP API 来完成的。此外,音乐卡片本质是 QQ 互联的一种表现形式,由 LightApp 承载。更好的解决方案可能是向 Milky 提出增加发送 音乐卡片尴尬的地方就在于,它本身从设计哲学的角度上不能算作一个消息段,也不足以给一个 API 命名,但它确实为许多人所用。 |
Author
Author
🤔 sokka |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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