This commit is contained in:
Him188 2020-04-15 17:01:04 +08:00
parent 77a0ba6e29
commit b30c380637
3 changed files with 14 additions and 13 deletions

View File

@ -331,7 +331,7 @@ internal class GroupImpl(
}.sendAndExpect() }.sendAndExpect()
if (response is MessageSvc.PbSendMsg.Response.Failed) { if (response is MessageSvc.PbSendMsg.Response.Failed) {
when (response.resultType) { when (response.resultType) {
120 -> error("bot is being muted.") 120 -> throw BotIsBeingMutedException(this@GroupImpl)
34 -> { 34 -> {
kotlin.runCatching { // allow retry once kotlin.runCatching { // allow retry once
return bot.lowLevelSendLongGroupMessage(id, msg) return bot.lowLevelSendLongGroupMessage(id, msg)

View File

@ -105,8 +105,8 @@ internal class MemberImpl constructor(
@Suppress("PropertyName") @Suppress("PropertyName")
var _muteTimestamp: Int = memberInfo.muteTimestamp var _muteTimestamp: Int = memberInfo.muteTimestamp
override val muteTimeRemaining: Int = override val muteTimeRemaining: Int
if (_muteTimestamp == 0 || _muteTimestamp == 0xFFFFFFFF.toInt()) { get() = if (_muteTimestamp == 0 || _muteTimestamp == 0xFFFFFFFF.toInt()) {
0 0
} else { } else {
(_muteTimestamp - currentTimeSeconds.toInt()).coerceAtLeast(0) (_muteTimestamp - currentTimeSeconds.toInt()).coerceAtLeast(0)

View File

@ -261,10 +261,10 @@ internal class OnlinePush {
readUInt().toLong() // time readUInt().toLong() // time
this.discardExact(2) this.discardExact(2)
val target = readUInt().toLong() val target = readUInt().toLong()
val time = readInt() val timeSeconds = readInt()
if (target == 0L) { if (target == 0L) {
val new = time != 0 val new = timeSeconds != 0
if (group.settings.isMuteAll == new) { if (group.settings.isMuteAll == new) {
return@lambda732 emptySequence() return@lambda732 emptySequence()
} }
@ -274,14 +274,15 @@ internal class OnlinePush {
if (target == bot.id) { if (target == bot.id) {
return@lambda732 when { return@lambda732 when {
group.botMuteRemaining == time -> emptySequence() group.botMuteRemaining == timeSeconds -> emptySequence()
time == 0 -> { timeSeconds == 0 || timeSeconds == 0xFFFF_FFFF.toInt() -> {
group.botAsMember.checkIsMemberImpl()._muteTimestamp = 0 group.botAsMember.checkIsMemberImpl()._muteTimestamp = 0
sequenceOf(BotUnmuteEvent(operator)) sequenceOf(BotUnmuteEvent(operator))
} }
else -> { else -> {
group.botAsMember.checkIsMemberImpl()._muteTimestamp = currentTimeSeconds.toInt() + time group.botAsMember.checkIsMemberImpl()._muteTimestamp =
sequenceOf(BotMuteEvent(time, operator)) currentTimeSeconds.toInt() + timeSeconds
sequenceOf(BotMuteEvent(timeSeconds, operator))
} }
} }
} }
@ -289,13 +290,13 @@ internal class OnlinePush {
val member = group.getOrNull(target) ?: return@lambda732 emptySequence() val member = group.getOrNull(target) ?: return@lambda732 emptySequence()
member.checkIsMemberImpl() member.checkIsMemberImpl()
if (member._muteTimestamp == time) { if (member._muteTimestamp == timeSeconds) {
return@lambda732 emptySequence() return@lambda732 emptySequence()
} }
member._muteTimestamp = time member._muteTimestamp = timeSeconds
return@lambda732 if (time == 0) sequenceOf(MemberUnmuteEvent(member, operator)) return@lambda732 if (timeSeconds == 0) sequenceOf(MemberUnmuteEvent(member, operator))
else sequenceOf(MemberMuteEvent(member, time, operator)) else sequenceOf(MemberMuteEvent(member, timeSeconds, operator))
}, },
// anonymous // anonymous