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
|
||||
func (c *QQClient) buildGroupSendingPacket(groupCode int64, r int32, forward bool, m *message.SendingMessage) (uint16, []byte) {
|
||||
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{}
|
||||
}
|
||||
|
||||
req := &msg.SendMessageRequest{
|
||||
RoutingHead: &msg.RoutingHead{Grp: &msg.Grp{GroupCode: groupCode}},
|
||||
ContentHead: &msg.ContentHead{PkgNum: 1},
|
||||
MsgBody: &msg.MessageBody{
|
||||
RichText: &msg.RichText{
|
||||
Elems: message.ToProtoElems(m.Elements, true),
|
||||
Ptt: m.Ptt,
|
||||
Ptt: func() *msg.Ptt {
|
||||
if ptt != nil {
|
||||
return ptt.Ptt
|
||||
}
|
||||
return nil
|
||||
}(),
|
||||
},
|
||||
},
|
||||
MsgSeq: c.nextGroupSeq(),
|
||||
|
@ -429,7 +429,7 @@ func (c *QQClient) uploadPrivateImage(target int64, img []byte, count int) (*mes
|
||||
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)
|
||||
seq, pkt := c.buildGroupPttStorePacket(groupCode, h[:], int32(len(voice)), voiceLength)
|
||||
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")
|
||||
ok:
|
||||
return &message.GroupPtt{
|
||||
Ptt: msg.Ptt{
|
||||
return &message.GroupVoiceElement{
|
||||
Ptt: &msg.Ptt{
|
||||
FileType: 4,
|
||||
SrcUin: c.Uin,
|
||||
FileMd5: h[:],
|
||||
|
@ -25,6 +25,10 @@ type GroupImageElement struct {
|
||||
Url string
|
||||
}
|
||||
|
||||
type GroupVoiceElement struct {
|
||||
Ptt *msg.Ptt
|
||||
}
|
||||
|
||||
type FriendImageElement struct {
|
||||
ImageId string
|
||||
Md5 []byte
|
||||
@ -68,10 +72,6 @@ type ForwardElement struct {
|
||||
ResId string
|
||||
}
|
||||
|
||||
type GroupPtt struct {
|
||||
Ptt msg.Ptt
|
||||
}
|
||||
|
||||
func NewText(s string) *TextElement {
|
||||
return &TextElement{Content: s}
|
||||
}
|
||||
@ -181,6 +181,10 @@ func (e *GroupFileElement) Type() ElementType {
|
||||
return File
|
||||
}
|
||||
|
||||
func (e *GroupVoiceElement) Type() ElementType {
|
||||
return Voice
|
||||
}
|
||||
|
||||
var faceMap = map[int]string{
|
||||
14: "微笑",
|
||||
1: "撇嘴",
|
||||
|
@ -44,7 +44,6 @@ type (
|
||||
|
||||
SendingMessage struct {
|
||||
Elements []IMessageElement
|
||||
Ptt *msg.Ptt
|
||||
}
|
||||
|
||||
ForwardMessage struct {
|
||||
@ -161,6 +160,15 @@ func (msg *SendingMessage) Any(filter func(e IMessageElement) bool) bool {
|
||||
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) {
|
||||
for _, e := range msg.Elements {
|
||||
if filter(e) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user