mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 19:17:38 +08:00
fix msg receipt.
This commit is contained in:
parent
6c18a70565
commit
a56a314a61
@ -75,8 +75,9 @@ type (
|
|||||||
MaxMemberCount uint16
|
MaxMemberCount uint16
|
||||||
Members []*GroupMemberInfo
|
Members []*GroupMemberInfo
|
||||||
|
|
||||||
client *QQClient
|
client *QQClient
|
||||||
lock sync.RWMutex
|
lastMsgSeq int64
|
||||||
|
lock sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
GroupMemberInfo struct {
|
GroupMemberInfo struct {
|
||||||
|
@ -44,6 +44,7 @@ func (c *QQClient) buildGroupInfoRequestPacket(groupCode int64) (uint16, []byte)
|
|||||||
GroupMemo: EmptyBytes,
|
GroupMemo: EmptyBytes,
|
||||||
GroupFingerMemo: EmptyBytes,
|
GroupFingerMemo: EmptyBytes,
|
||||||
GroupLastMsgTime: proto.Uint32(0),
|
GroupLastMsgTime: proto.Uint32(0),
|
||||||
|
GroupCurMsgSeq: proto.Uint32(0),
|
||||||
GroupQuestion: EmptyBytes,
|
GroupQuestion: EmptyBytes,
|
||||||
GroupAnswer: EmptyBytes,
|
GroupAnswer: EmptyBytes,
|
||||||
GroupGrade: proto.Uint32(0),
|
GroupGrade: proto.Uint32(0),
|
||||||
@ -146,6 +147,7 @@ func decodeGroupInfoResponse(c *QQClient, _ uint16, payload []byte) (interface{}
|
|||||||
MemberCount: uint16(*info.GroupInfo.GroupMemberNum),
|
MemberCount: uint16(*info.GroupInfo.GroupMemberNum),
|
||||||
MaxMemberCount: uint16(*info.GroupInfo.GroupMemberMaxNum),
|
MaxMemberCount: uint16(*info.GroupInfo.GroupMemberMaxNum),
|
||||||
Members: []*GroupMemberInfo{},
|
Members: []*GroupMemberInfo{},
|
||||||
|
lastMsgSeq: int64(info.GroupInfo.GetGroupCurMsgSeq()),
|
||||||
client: c,
|
client: c,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,7 @@ func (c *QQClient) sendGroupMessage(groupCode int64, forward bool, m *message.Se
|
|||||||
eid := utils.RandomString(6)
|
eid := utils.RandomString(6)
|
||||||
mr := int32(rand.Uint32())
|
mr := int32(rand.Uint32())
|
||||||
ch := make(chan int32)
|
ch := make(chan int32)
|
||||||
|
defer close(ch)
|
||||||
c.onGroupMessageReceipt(eid, func(c *QQClient, e *groupMessageReceiptEvent) {
|
c.onGroupMessageReceipt(eid, func(c *QQClient, e *groupMessageReceiptEvent) {
|
||||||
if e.Rand == mr {
|
if e.Rand == mr {
|
||||||
ch <- e.Seq
|
ch <- e.Seq
|
||||||
@ -107,7 +108,16 @@ func (c *QQClient) sendGroupMessage(groupCode int64, forward bool, m *message.Se
|
|||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
case mid = <-ch:
|
case mid = <-ch:
|
||||||
case <-time.After(time.Second * 5):
|
case <-time.After(time.Second * 3):
|
||||||
|
if g, err := c.GetGroupInfo(groupCode); err == nil {
|
||||||
|
if history, err := c.GetGroupMessages(groupCode, g.lastMsgSeq-10, g.lastMsgSeq+1); err == nil {
|
||||||
|
for _, m := range history {
|
||||||
|
if m.InternalId == mr {
|
||||||
|
return m
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
ret.Id = mid
|
ret.Id = mid
|
||||||
|
Loading…
x
Reference in New Issue
Block a user