Filter out duplicated GroupTalkativeChangeEvent and relevant events with same subject. Fix #1707

This commit is contained in:
Him188 2021-12-21 22:55:54 +00:00
parent aa53d92fbe
commit 10af69f05e
2 changed files with 8 additions and 2 deletions

View File

@ -12,6 +12,7 @@
package net.mamoe.mirai.internal.contact
import kotlinx.atomicfu.atomic
import net.mamoe.mirai.LowLevelApi
import net.mamoe.mirai.Mirai
import net.mamoe.mirai.contact.*
@ -114,6 +115,7 @@ internal class GroupImpl constructor(
override val filesRoot: RemoteFile by lazy { RemoteFileImpl(this, "/") }
override val files: RemoteFiles by lazy { RemoteFilesImpl(this) }
val lastTalkative = atomic<NormalMemberImpl?>(null)
override val announcements: Announcements by lazy {
AnnouncementsImpl(

View File

@ -347,8 +347,12 @@ internal class GroupNotificationProcessor(
}
// 龙王
10093L, 1053L, 1054L -> {
val now: NormalMember = grayTip.msgTemplParam["uin"]?.findMember() ?: group.botAsMember
val previous: NormalMember? = grayTip.msgTemplParam["uin_last"]?.findMember()
val now = grayTip.msgTemplParam["uin"]?.findMember() ?: group.botAsMember
val previous = grayTip.msgTemplParam["uin_last"]?.findMember()
val lastTalkative = group.lastTalkative.value
if (lastTalkative == now) return // duplicate
if (!group.lastTalkative.compareAndSet(lastTalkative, now)) return
if (previous == null) {
collect(MemberHonorChangeEvent.Achieve(now, GroupHonorType.TALKATIVE))