diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/contact/GroupImpl.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/contact/GroupImpl.kt index f22649770..a32d24bf2 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/contact/GroupImpl.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/contact/GroupImpl.kt @@ -331,7 +331,7 @@ internal class GroupImpl( }.sendAndExpect() if (response is MessageSvc.PbSendMsg.Response.Failed) { when (response.resultType) { - 120 -> error("bot is being muted.") + 120 -> throw BotIsBeingMutedException(this@GroupImpl) 34 -> { kotlin.runCatching { // allow retry once return bot.lowLevelSendLongGroupMessage(id, msg) diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/contact/MemberImpl.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/contact/MemberImpl.kt index ad585201b..b6062d7df 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/contact/MemberImpl.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/contact/MemberImpl.kt @@ -105,8 +105,8 @@ internal class MemberImpl constructor( @Suppress("PropertyName") var _muteTimestamp: Int = memberInfo.muteTimestamp - override val muteTimeRemaining: Int = - if (_muteTimestamp == 0 || _muteTimestamp == 0xFFFFFFFF.toInt()) { + override val muteTimeRemaining: Int + get() = if (_muteTimestamp == 0 || _muteTimestamp == 0xFFFFFFFF.toInt()) { 0 } else { (_muteTimestamp - currentTimeSeconds.toInt()).coerceAtLeast(0) diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/OnlinePush.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/OnlinePush.kt index 272dfc0b6..5dc21c6d5 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/OnlinePush.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/OnlinePush.kt @@ -261,10 +261,10 @@ internal class OnlinePush { readUInt().toLong() // time this.discardExact(2) val target = readUInt().toLong() - val time = readInt() + val timeSeconds = readInt() if (target == 0L) { - val new = time != 0 + val new = timeSeconds != 0 if (group.settings.isMuteAll == new) { return@lambda732 emptySequence() } @@ -274,14 +274,15 @@ internal class OnlinePush { if (target == bot.id) { return@lambda732 when { - group.botMuteRemaining == time -> emptySequence() - time == 0 -> { + group.botMuteRemaining == timeSeconds -> emptySequence() + timeSeconds == 0 || timeSeconds == 0xFFFF_FFFF.toInt() -> { group.botAsMember.checkIsMemberImpl()._muteTimestamp = 0 sequenceOf(BotUnmuteEvent(operator)) } else -> { - group.botAsMember.checkIsMemberImpl()._muteTimestamp = currentTimeSeconds.toInt() + time - sequenceOf(BotMuteEvent(time, operator)) + group.botAsMember.checkIsMemberImpl()._muteTimestamp = + currentTimeSeconds.toInt() + timeSeconds + sequenceOf(BotMuteEvent(timeSeconds, operator)) } } } @@ -289,13 +290,13 @@ internal class OnlinePush { val member = group.getOrNull(target) ?: return@lambda732 emptySequence() member.checkIsMemberImpl() - if (member._muteTimestamp == time) { + if (member._muteTimestamp == timeSeconds) { return@lambda732 emptySequence() } - member._muteTimestamp = time - return@lambda732 if (time == 0) sequenceOf(MemberUnmuteEvent(member, operator)) - else sequenceOf(MemberMuteEvent(member, time, operator)) + member._muteTimestamp = timeSeconds + return@lambda732 if (timeSeconds == 0) sequenceOf(MemberUnmuteEvent(member, operator)) + else sequenceOf(MemberMuteEvent(member, timeSeconds, operator)) }, // anonymous