mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 19:17:38 +08:00
clear music share api
This commit is contained in:
parent
fb93c5c731
commit
751bc2dca3
@ -16,8 +16,8 @@ import (
|
|||||||
"github.com/Mrs4s/MiraiGo/binary"
|
"github.com/Mrs4s/MiraiGo/binary"
|
||||||
"github.com/Mrs4s/MiraiGo/binary/jce"
|
"github.com/Mrs4s/MiraiGo/binary/jce"
|
||||||
devinfo "github.com/Mrs4s/MiraiGo/client/pb"
|
devinfo "github.com/Mrs4s/MiraiGo/client/pb"
|
||||||
"github.com/Mrs4s/MiraiGo/client/pb/oidb"
|
|
||||||
"github.com/Mrs4s/MiraiGo/client/pb/msg"
|
"github.com/Mrs4s/MiraiGo/client/pb/msg"
|
||||||
|
"github.com/Mrs4s/MiraiGo/client/pb/oidb"
|
||||||
"github.com/Mrs4s/MiraiGo/message"
|
"github.com/Mrs4s/MiraiGo/message"
|
||||||
"github.com/Mrs4s/MiraiGo/utils"
|
"github.com/Mrs4s/MiraiGo/utils"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
@ -12,14 +12,60 @@ import (
|
|||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RichClientInfo struct {
|
type musicTypeInfo struct {
|
||||||
Platform uint32
|
appID uint64
|
||||||
SdkVersion string
|
appType uint32
|
||||||
PackageName string
|
platform uint32
|
||||||
Signature string
|
sdkVersion string
|
||||||
|
packageName string
|
||||||
|
signature string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *QQClient) SendGroupRichMessage(target, appId int64, appType, msgStyle uint32, client RichClientInfo, msg *message.RichMessage) (*message.GroupMessage, error) {
|
var musicType = [...]musicTypeInfo{
|
||||||
|
{ // QQMusic
|
||||||
|
appID: 100497308,
|
||||||
|
appType: 1,
|
||||||
|
platform: 1,
|
||||||
|
sdkVersion: "0.0.0",
|
||||||
|
packageName: "com.tencent.qqmusic",
|
||||||
|
signature: "cbd27cd7c861227d013a25b2d10f0799",
|
||||||
|
},
|
||||||
|
{ // NeteaseMusic
|
||||||
|
appID: 100495085,
|
||||||
|
appType: 1,
|
||||||
|
platform: 1,
|
||||||
|
sdkVersion: "0.0.0",
|
||||||
|
packageName: "com.netease.cloudmusic",
|
||||||
|
signature: "da6b069da1e2982db3e386233f68d76d",
|
||||||
|
},
|
||||||
|
{ // MiguMusic
|
||||||
|
appID: 1101053067,
|
||||||
|
appType: 1,
|
||||||
|
platform: 1,
|
||||||
|
sdkVersion: "0.0.0",
|
||||||
|
packageName: "cmccwm.mobilemusic",
|
||||||
|
signature: "6cdc72a439cef99a3418d2a78aa28c73",
|
||||||
|
},
|
||||||
|
{ // KugouMusic
|
||||||
|
appID: 205141,
|
||||||
|
appType: 1,
|
||||||
|
platform: 1,
|
||||||
|
sdkVersion: "0.0.0",
|
||||||
|
packageName: "com.kugou.android",
|
||||||
|
signature: "fe4a24d80fcf253a00676a808f62c2c6",
|
||||||
|
},
|
||||||
|
{ // KuwoMusic
|
||||||
|
appID: 100243533,
|
||||||
|
appType: 1,
|
||||||
|
platform: 1,
|
||||||
|
sdkVersion: "0.0.0",
|
||||||
|
packageName: "cn.kuwo.player",
|
||||||
|
signature: "bf9ff4ffb4c558a34ee3fd52c223ebf5",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// SendGroupMusicShare 发送群聊音乐卡片
|
||||||
|
func (c *QQClient) SendGroupMusicShare(target int64, msg *message.MusicShareElement) (*message.GroupMessage, error) {
|
||||||
ch := make(chan *message.GroupMessage)
|
ch := make(chan *message.GroupMessage)
|
||||||
eid := utils.RandomString(6)
|
eid := utils.RandomString(6)
|
||||||
c.onGroupMessageReceipt(eid, func(c *QQClient, e *groupMessageReceiptEvent) {
|
c.onGroupMessageReceipt(eid, func(c *QQClient, e *groupMessageReceiptEvent) {
|
||||||
@ -30,7 +76,7 @@ func (c *QQClient) SendGroupRichMessage(target, appId int64, appType, msgStyle u
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
defer c.onGroupMessageReceipt(eid)
|
defer c.onGroupMessageReceipt(eid)
|
||||||
_, _ = c.sendAndWait(c.buildRichMsgSendingPacket(target, appId, appType, msgStyle, 1, client, msg)) // rsp is empty chunk
|
_, _ = c.sendAndWait(c.buildRichMsgSendingPacket(target, msg, 1)) // rsp is empty chunk
|
||||||
select {
|
select {
|
||||||
case ret := <-ch:
|
case ret := <-ch:
|
||||||
return ret, nil
|
return ret, nil
|
||||||
@ -39,22 +85,29 @@ func (c *QQClient) SendGroupRichMessage(target, appId int64, appType, msgStyle u
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *QQClient) SendFriendRichMessage(target, appId int64, appType, msgStyle uint32, client RichClientInfo, msg *message.RichMessage) {
|
// SendFriendMusicShare 发送好友音乐卡片
|
||||||
_, _ = c.sendAndWait(c.buildRichMsgSendingPacket(target, appId, appType, msgStyle, 0, client, msg))
|
func (c *QQClient) SendFriendMusicShare(target int64, msg *message.MusicShareElement) {
|
||||||
|
_, _ = c.sendAndWait(c.buildRichMsgSendingPacket(target, msg, 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
// OidbSvc.0xb77_9
|
// OidbSvc.0xb77_9
|
||||||
func (c *QQClient) buildRichMsgSendingPacket(target, appId int64, appType, msgStyle, sendType uint32, client RichClientInfo, msg *message.RichMessage) (uint16, []byte) {
|
func (c *QQClient) buildRichMsgSendingPacket(target int64, msg *message.MusicShareElement, sendType uint32) (uint16, []byte) {
|
||||||
seq := c.nextSeq()
|
seq := c.nextSeq()
|
||||||
|
tp := musicType[msg.MusicType] // MusicType
|
||||||
body := &oidb.DB77ReqBody{
|
body := &oidb.DB77ReqBody{
|
||||||
AppId: uint64(appId),
|
AppId: tp.appID,
|
||||||
AppType: appType,
|
AppType: tp.appType,
|
||||||
MsgStyle: msgStyle,
|
MsgStyle: func() uint32 {
|
||||||
|
if msg.MusicUrl == "" {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return 4
|
||||||
|
}(),
|
||||||
ClientInfo: &oidb.DB77ClientInfo{
|
ClientInfo: &oidb.DB77ClientInfo{
|
||||||
Platform: client.Platform,
|
Platform: tp.platform,
|
||||||
SdkVersion: client.SdkVersion,
|
SdkVersion: tp.sdkVersion,
|
||||||
AndroidPackageName: client.PackageName,
|
AndroidPackageName: tp.packageName,
|
||||||
AndroidSignature: client.Signature,
|
AndroidSignature: tp.signature,
|
||||||
},
|
},
|
||||||
ExtInfo: &oidb.DB77ExtInfo{MsgSeq: rand.Uint64()},
|
ExtInfo: &oidb.DB77ExtInfo{MsgSeq: rand.Uint64()},
|
||||||
SendType: sendType,
|
SendType: sendType,
|
||||||
@ -69,13 +122,7 @@ func (c *QQClient) buildRichMsgSendingPacket(target, appId int64, appType, msgSt
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
b, _ := proto.Marshal(body)
|
b, _ := proto.Marshal(body)
|
||||||
req := &oidb.OIDBSSOPkg{
|
payload := c.packOIDBPackage(2935, 9, b)
|
||||||
Command: 2935,
|
|
||||||
ServiceType: 9,
|
|
||||||
Bodybuffer: b,
|
|
||||||
ClientVersion: "android 8.4.8",
|
|
||||||
}
|
|
||||||
payload, _ := proto.Marshal(req)
|
|
||||||
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0xb77_9", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
|
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0xb77_9", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
|
||||||
return seq, packet
|
return seq, packet
|
||||||
}
|
}
|
||||||
|
@ -120,6 +120,19 @@ type RedBagElement struct {
|
|||||||
Title string
|
Title string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MusicShareElement 音乐分享卡片
|
||||||
|
//
|
||||||
|
// 请使用 SendGroupMusicShare 或者 SendFriendMusicShare 发送
|
||||||
|
type MusicShareElement struct {
|
||||||
|
MusicType int // 音乐类型,请使用 QQMusic 等常量
|
||||||
|
Title string // 标题(歌曲名)
|
||||||
|
Brief string
|
||||||
|
Summary string // 简介(歌手名)
|
||||||
|
Url string // 点击跳转链接
|
||||||
|
PictureUrl string // 显示图片链接
|
||||||
|
MusicUrl string // 音乐播放链接
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: 总之就是非常傻逼
|
// TODO: 总之就是非常傻逼
|
||||||
|
|
||||||
type GroupFlashImgElement struct {
|
type GroupFlashImgElement struct {
|
||||||
@ -323,6 +336,11 @@ func (e *LightAppElement) Type() ElementType {
|
|||||||
return LightApp
|
return LightApp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Type implement message.IMessageElement
|
||||||
|
func (e *MusicShareElement) Type() ElementType {
|
||||||
|
return LightApp
|
||||||
|
}
|
||||||
|
|
||||||
func (e *RedBagElement) Type() ElementType {
|
func (e *RedBagElement) Type() ElementType {
|
||||||
return RedBag
|
return RedBag
|
||||||
}
|
}
|
||||||
|
@ -62,15 +62,6 @@ type (
|
|||||||
Message []IMessageElement
|
Message []IMessageElement
|
||||||
}
|
}
|
||||||
|
|
||||||
RichMessage struct {
|
|
||||||
Title string
|
|
||||||
Summary string
|
|
||||||
Brief string
|
|
||||||
Url string
|
|
||||||
PictureUrl string
|
|
||||||
MusicUrl string
|
|
||||||
}
|
|
||||||
|
|
||||||
Sender struct {
|
Sender struct {
|
||||||
Uin int64
|
Uin int64
|
||||||
Nickname string
|
Nickname string
|
||||||
@ -97,6 +88,15 @@ type (
|
|||||||
GroupGift int
|
GroupGift int
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// MusicType values.
|
||||||
|
const (
|
||||||
|
QQMusic = iota // QQ音乐
|
||||||
|
CloudMusic // 网易云音乐
|
||||||
|
MiguMusic // 咪咕音乐
|
||||||
|
KugouMusic // 酷狗音乐
|
||||||
|
KuwoMusic // 酷我音乐
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Text ElementType = iota
|
Text ElementType = iota
|
||||||
Image
|
Image
|
||||||
|
Loading…
x
Reference in New Issue
Block a user