mirror of
https://github.com/mamoe/mirai.git
synced 2025-02-13 03:16:05 +08:00
Fix #247
This commit is contained in:
parent
6f69497247
commit
4a217d83a6
@ -155,6 +155,20 @@ internal open class QQAndroidClient(
|
|||||||
private val messageSequenceId: AtomicInt = atomic(22911)
|
private val messageSequenceId: AtomicInt = atomic(22911)
|
||||||
internal fun atomicNextMessageSequenceId(): Int = messageSequenceId.getAndAdd(2)
|
internal fun atomicNextMessageSequenceId(): Int = messageSequenceId.getAndAdd(2)
|
||||||
|
|
||||||
|
|
||||||
|
private val friendSeq: AtomicInt = atomic(22911)
|
||||||
|
internal fun getFriendSeq(): Int {
|
||||||
|
return friendSeq.value
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun nextFriendSeq(): Int {
|
||||||
|
return friendSeq.incrementAndGet()
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun setFriendSeq(compare: Int, id: Int): Boolean {
|
||||||
|
return friendSeq.compareAndSet(compare, id % 65535)
|
||||||
|
}
|
||||||
|
|
||||||
private val requestPacketRequestId: AtomicInt = atomic(1921334513)
|
private val requestPacketRequestId: AtomicInt = atomic(1921334513)
|
||||||
internal fun nextRequestPacketRequestId(): Int = requestPacketRequestId.getAndAdd(2)
|
internal fun nextRequestPacketRequestId(): Int = requestPacketRequestId.getAndAdd(2)
|
||||||
|
|
||||||
|
@ -229,10 +229,21 @@ internal class MessageSvc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
166 -> {
|
166 -> {
|
||||||
|
if (msg.msgHead.fromUin == bot.id) {
|
||||||
|
loop@ while (true) {
|
||||||
|
val instance = bot.client.getFriendSeq()
|
||||||
|
if (instance < msg.msgHead.msgSeq) {
|
||||||
|
if (bot.client.setFriendSeq(instance, msg.msgHead.msgSeq)) {
|
||||||
|
break@loop
|
||||||
|
}
|
||||||
|
} else break@loop
|
||||||
|
}
|
||||||
|
return@mapNotNull null
|
||||||
|
}
|
||||||
val friend = bot.getFriendOrNull(msg.msgHead.fromUin) ?: return@mapNotNull null
|
val friend = bot.getFriendOrNull(msg.msgHead.fromUin) ?: return@mapNotNull null
|
||||||
friend.checkIsFriendImpl()
|
friend.checkIsFriendImpl()
|
||||||
|
|
||||||
if (msg.msgHead.fromUin == bot.id || !bot.firstLoginSucceed) {
|
if (!bot.firstLoginSucceed) {
|
||||||
return@mapNotNull null
|
return@mapNotNull null
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -376,7 +387,7 @@ internal class MessageSvc {
|
|||||||
sender = client.bot,
|
sender = client.bot,
|
||||||
target = qq,
|
target = qq,
|
||||||
time = currentTimeSeconds.toInt(),
|
time = currentTimeSeconds.toInt(),
|
||||||
sequenceId = rand,
|
sequenceId = client.nextFriendSeq(),
|
||||||
originalMessage = message
|
originalMessage = message
|
||||||
)
|
)
|
||||||
sourceCallback(source)
|
sourceCallback(source)
|
||||||
|
Loading…
Reference in New Issue
Block a user