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()
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)

View File

@ -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)

View File

@ -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