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
@ -76,6 +76,7 @@ type (
|
||||
Members []*GroupMemberInfo
|
||||
|
||||
client *QQClient
|
||||
lastMsgSeq int64
|
||||
lock sync.RWMutex
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,7 @@ func (c *QQClient) buildGroupInfoRequestPacket(groupCode int64) (uint16, []byte)
|
||||
GroupMemo: EmptyBytes,
|
||||
GroupFingerMemo: EmptyBytes,
|
||||
GroupLastMsgTime: proto.Uint32(0),
|
||||
GroupCurMsgSeq: proto.Uint32(0),
|
||||
GroupQuestion: EmptyBytes,
|
||||
GroupAnswer: EmptyBytes,
|
||||
GroupGrade: proto.Uint32(0),
|
||||
@ -146,6 +147,7 @@ func decodeGroupInfoResponse(c *QQClient, _ uint16, payload []byte) (interface{}
|
||||
MemberCount: uint16(*info.GroupInfo.GroupMemberNum),
|
||||
MaxMemberCount: uint16(*info.GroupInfo.GroupMemberMaxNum),
|
||||
Members: []*GroupMemberInfo{},
|
||||
lastMsgSeq: int64(info.GroupInfo.GetGroupCurMsgSeq()),
|
||||
client: c,
|
||||
}, nil
|
||||
}
|
||||
|
@ -69,6 +69,7 @@ func (c *QQClient) sendGroupMessage(groupCode int64, forward bool, m *message.Se
|
||||
eid := utils.RandomString(6)
|
||||
mr := int32(rand.Uint32())
|
||||
ch := make(chan int32)
|
||||
defer close(ch)
|
||||
c.onGroupMessageReceipt(eid, func(c *QQClient, e *groupMessageReceiptEvent) {
|
||||
if e.Rand == mr {
|
||||
ch <- e.Seq
|
||||
@ -107,7 +108,16 @@ func (c *QQClient) sendGroupMessage(groupCode int64, forward bool, m *message.Se
|
||||
}
|
||||
select {
|
||||
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
|
||||
}
|
||||
ret.Id = mid
|
||||
|
Loading…
x
Reference in New Issue
Block a user