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 507b35dcb7
commit 0c169d0068
2 changed files with 3 additions and 3 deletions

View File

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

View File

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