mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 11:07:40 +08:00
feat: guild at encode
This commit is contained in:
parent
55ba62e4b8
commit
511e8c41ed
@ -42,6 +42,13 @@ func init() {
|
|||||||
|
|
||||||
func (s *GuildService) SendGuildChannelMessage(guildId, channelId uint64, m *message.SendingMessage) (*message.GuildChannelMessage, error) {
|
func (s *GuildService) SendGuildChannelMessage(guildId, channelId uint64, m *message.SendingMessage) (*message.GuildChannelMessage, error) {
|
||||||
mr := rand.Uint32() // 客户端似乎是生成的 u32 虽然类型是u64
|
mr := rand.Uint32() // 客户端似乎是生成的 u32 虽然类型是u64
|
||||||
|
at := m.FirstOrNil(func(e message.IMessageElement) bool {
|
||||||
|
_, ok := e.(*message.AtElement)
|
||||||
|
return ok
|
||||||
|
})
|
||||||
|
if at != nil {
|
||||||
|
at.(*message.AtElement).Guild = true
|
||||||
|
}
|
||||||
req := &channel.DF62ReqBody{Msg: &channel.ChannelMsgContent{
|
req := &channel.DF62ReqBody{Msg: &channel.ChannelMsgContent{
|
||||||
Head: &channel.ChannelMsgHead{
|
Head: &channel.ChannelMsgHead{
|
||||||
RoutingHead: &channel.ChannelRoutingHead{
|
RoutingHead: &channel.ChannelRoutingHead{
|
||||||
|
@ -41,6 +41,7 @@ type FaceElement struct {
|
|||||||
type AtElement struct {
|
type AtElement struct {
|
||||||
Target int64
|
Target int64
|
||||||
Display string
|
Display string
|
||||||
|
Guild bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type GroupFileElement struct {
|
type GroupFileElement struct {
|
||||||
|
@ -385,7 +385,9 @@ func ParseMessageElems(elems []*msg.Elem) []IMessageElement {
|
|||||||
resv := new(msg.TextResvAttr)
|
resv := new(msg.TextResvAttr)
|
||||||
_ = proto.Unmarshal(elem.Text.PbReserve, resv)
|
_ = proto.Unmarshal(elem.Text.PbReserve, resv)
|
||||||
if resv.GetAtType() == 2 {
|
if resv.GetAtType() == 2 {
|
||||||
res = append(res, NewAt(int64(resv.GetAtMemberTinyid()), elem.Text.GetStr()))
|
at := NewAt(int64(resv.GetAtMemberTinyid()), elem.Text.GetStr())
|
||||||
|
at.Guild = true
|
||||||
|
res = append(res, at)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
fallthrough
|
fallthrough
|
||||||
|
@ -56,24 +56,34 @@ func (e *FaceElement) Pack() (r []*msg.Elem) {
|
|||||||
|
|
||||||
func (e *AtElement) Pack() (r []*msg.Elem) {
|
func (e *AtElement) Pack() (r []*msg.Elem) {
|
||||||
r = []*msg.Elem{}
|
r = []*msg.Elem{}
|
||||||
r = append(r, &msg.Elem{
|
if e.Guild {
|
||||||
Text: &msg.Text{
|
pb, _ := proto.Marshal(&msg.TextResvAttr{AtType: proto.Uint32(2), AtMemberTinyid: proto.Uint64(uint64(e.Target))})
|
||||||
Str: &e.Display,
|
r = append(r, &msg.Elem{
|
||||||
Attr6Buf: binary.NewWriterF(func(w *binary.Writer) {
|
Text: &msg.Text{
|
||||||
w.WriteUInt16(1)
|
Str: &e.Display,
|
||||||
w.WriteUInt16(0)
|
PbReserve: pb,
|
||||||
w.WriteUInt16(uint16(len([]rune(e.Display))))
|
},
|
||||||
w.WriteByte(func() byte {
|
})
|
||||||
if e.Target == 0 {
|
} else {
|
||||||
return 1
|
r = append(r, &msg.Elem{
|
||||||
}
|
Text: &msg.Text{
|
||||||
return 0
|
Str: &e.Display,
|
||||||
}())
|
Attr6Buf: binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt32(uint32(e.Target))
|
w.WriteUInt16(1)
|
||||||
w.WriteUInt16(0)
|
w.WriteUInt16(0)
|
||||||
}),
|
w.WriteUInt16(uint16(len([]rune(e.Display))))
|
||||||
},
|
w.WriteByte(func() byte {
|
||||||
})
|
if e.Target == 0 {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}())
|
||||||
|
w.WriteUInt32(uint32(e.Target))
|
||||||
|
w.WriteUInt16(0)
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
r = append(r, &msg.Elem{Text: &msg.Text{Str: proto.String(" ")}})
|
r = append(r, &msg.Elem{Text: &msg.Text{Str: proto.String(" ")}})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user