Improve stability, returns -1 for sequenceId when failed to fetch from server

This commit is contained in:
Him188 2020-05-28 13:50:52 +08:00
parent a084eac8be
commit f653f33a6f
2 changed files with 3 additions and 3 deletions

View File

@ -128,8 +128,8 @@ internal class MessageSourceToGroupImpl(
@OptIn(ExperimentalCoroutinesApi::class)
override val sequenceId: Int
get() = when {
sequenceIdDeferred.isCompleted -> sequenceIdDeferred.getCompleted() ?: 0
!sequenceIdDeferred.isActive -> 0
sequenceIdDeferred.isCompleted -> sequenceIdDeferred.getCompleted() ?: -1
!sequenceIdDeferred.isActive -> -1
else -> error("sequenceId not yet available")
}

View File

@ -76,7 +76,7 @@ sealed class MessageSource : Message, MessageMetadata, ConstrainSingle<MessageSo
abstract val bot: Bot
/**
* 消息 id (序列号).
* 消息 id (序列号). 在获取失败时 (概率很低) `-1`.
**
* #### 值域
* 值的范围约为 [UShort] 的范围.