mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 11:07:40 +08:00
add: GroupVoiceElement.
This commit is contained in:
parent
ed30f7ad59
commit
371a7516fe
@ -385,17 +385,23 @@ func (c *QQClient) buildDeleteOnlinePushPacket(uin int64, seq uint16, delMsg []j
|
|||||||
// MessageSvc.PbSendMsg
|
// MessageSvc.PbSendMsg
|
||||||
func (c *QQClient) buildGroupSendingPacket(groupCode int64, r int32, forward bool, m *message.SendingMessage) (uint16, []byte) {
|
func (c *QQClient) buildGroupSendingPacket(groupCode int64, r int32, forward bool, m *message.SendingMessage) (uint16, []byte) {
|
||||||
seq := c.nextSeq()
|
seq := c.nextSeq()
|
||||||
if m.Ptt != nil {
|
var ptt *message.GroupVoiceElement
|
||||||
|
if i := m.FirstOrNil(func(e message.IMessageElement) bool { return e.Type() == message.Voice }); i != nil {
|
||||||
|
ptt = i.(*message.GroupVoiceElement)
|
||||||
m.Elements = []message.IMessageElement{}
|
m.Elements = []message.IMessageElement{}
|
||||||
}
|
}
|
||||||
|
|
||||||
req := &msg.SendMessageRequest{
|
req := &msg.SendMessageRequest{
|
||||||
RoutingHead: &msg.RoutingHead{Grp: &msg.Grp{GroupCode: groupCode}},
|
RoutingHead: &msg.RoutingHead{Grp: &msg.Grp{GroupCode: groupCode}},
|
||||||
ContentHead: &msg.ContentHead{PkgNum: 1},
|
ContentHead: &msg.ContentHead{PkgNum: 1},
|
||||||
MsgBody: &msg.MessageBody{
|
MsgBody: &msg.MessageBody{
|
||||||
RichText: &msg.RichText{
|
RichText: &msg.RichText{
|
||||||
Elems: message.ToProtoElems(m.Elements, true),
|
Elems: message.ToProtoElems(m.Elements, true),
|
||||||
Ptt: m.Ptt,
|
Ptt: func() *msg.Ptt {
|
||||||
|
if ptt != nil {
|
||||||
|
return ptt.Ptt
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
MsgSeq: c.nextGroupSeq(),
|
MsgSeq: c.nextGroupSeq(),
|
||||||
|
@ -429,7 +429,7 @@ func (c *QQClient) uploadPrivateImage(target int64, img []byte, count int) (*mes
|
|||||||
return e, nil
|
return e, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *QQClient) UploadGroupPtt(groupCode int64, voice []byte, voiceLength int32) (*message.GroupPtt, error) {
|
func (c *QQClient) UploadGroupPtt(groupCode int64, voice []byte, voiceLength int32) (*message.GroupVoiceElement, error) {
|
||||||
h := md5.Sum(voice)
|
h := md5.Sum(voice)
|
||||||
seq, pkt := c.buildGroupPttStorePacket(groupCode, h[:], int32(len(voice)), voiceLength)
|
seq, pkt := c.buildGroupPttStorePacket(groupCode, h[:], int32(len(voice)), voiceLength)
|
||||||
r, err := c.sendAndWait(seq, pkt)
|
r, err := c.sendAndWait(seq, pkt)
|
||||||
@ -452,8 +452,8 @@ func (c *QQClient) UploadGroupPtt(groupCode int64, voice []byte, voiceLength int
|
|||||||
}
|
}
|
||||||
return nil, errors.New("upload failed")
|
return nil, errors.New("upload failed")
|
||||||
ok:
|
ok:
|
||||||
return &message.GroupPtt{
|
return &message.GroupVoiceElement{
|
||||||
Ptt: msg.Ptt{
|
Ptt: &msg.Ptt{
|
||||||
FileType: 4,
|
FileType: 4,
|
||||||
SrcUin: c.Uin,
|
SrcUin: c.Uin,
|
||||||
FileMd5: h[:],
|
FileMd5: h[:],
|
||||||
|
@ -25,6 +25,10 @@ type GroupImageElement struct {
|
|||||||
Url string
|
Url string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GroupVoiceElement struct {
|
||||||
|
Ptt *msg.Ptt
|
||||||
|
}
|
||||||
|
|
||||||
type FriendImageElement struct {
|
type FriendImageElement struct {
|
||||||
ImageId string
|
ImageId string
|
||||||
Md5 []byte
|
Md5 []byte
|
||||||
@ -68,10 +72,6 @@ type ForwardElement struct {
|
|||||||
ResId string
|
ResId string
|
||||||
}
|
}
|
||||||
|
|
||||||
type GroupPtt struct {
|
|
||||||
Ptt msg.Ptt
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewText(s string) *TextElement {
|
func NewText(s string) *TextElement {
|
||||||
return &TextElement{Content: s}
|
return &TextElement{Content: s}
|
||||||
}
|
}
|
||||||
@ -181,6 +181,10 @@ func (e *GroupFileElement) Type() ElementType {
|
|||||||
return File
|
return File
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e *GroupVoiceElement) Type() ElementType {
|
||||||
|
return Voice
|
||||||
|
}
|
||||||
|
|
||||||
var faceMap = map[int]string{
|
var faceMap = map[int]string{
|
||||||
14: "微笑",
|
14: "微笑",
|
||||||
1: "撇嘴",
|
1: "撇嘴",
|
||||||
|
@ -44,7 +44,6 @@ type (
|
|||||||
|
|
||||||
SendingMessage struct {
|
SendingMessage struct {
|
||||||
Elements []IMessageElement
|
Elements []IMessageElement
|
||||||
Ptt *msg.Ptt
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ForwardMessage struct {
|
ForwardMessage struct {
|
||||||
@ -161,6 +160,15 @@ func (msg *SendingMessage) Any(filter func(e IMessageElement) bool) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (msg *SendingMessage) FirstOrNil(filter func(e IMessageElement) bool) IMessageElement {
|
||||||
|
for _, e := range msg.Elements {
|
||||||
|
if filter(e) {
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (msg *SendingMessage) Count(filter func(e IMessageElement) bool) (c int) {
|
func (msg *SendingMessage) Count(filter func(e IMessageElement) bool) (c int) {
|
||||||
for _, e := range msg.Elements {
|
for _, e := range msg.Elements {
|
||||||
if filter(e) {
|
if filter(e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user