Fix Message.Key

This commit is contained in:
Him188 2020-04-04 23:31:35 +08:00
parent 864cde060e
commit ca85eb6258
2 changed files with 13 additions and 0 deletions

View File

@ -147,6 +147,15 @@ fun <M : Message> MessageChain.firstOrNull(key: Message.Key<M>): M? = when (key)
Face -> firstOrNull<Face>() Face -> firstOrNull<Face>()
QuoteReply -> firstOrNull<QuoteReply>() QuoteReply -> firstOrNull<QuoteReply>()
MessageSource -> firstOrNull<MessageSource>() MessageSource -> firstOrNull<MessageSource>()
OnlineMessageSource -> firstOrNull<OnlineMessageSource>()
OfflineMessageSource -> firstOrNull<OfflineMessageSource>()
OnlineMessageSource.Outgoing -> firstOrNull<OnlineMessageSource.Outgoing>()
OnlineMessageSource.Outgoing.ToGroup -> firstOrNull<OnlineMessageSource.Outgoing.ToGroup>()
OnlineMessageSource.Outgoing.ToFriend -> firstOrNull<OnlineMessageSource.Outgoing.ToFriend>()
OnlineMessageSource.Incoming -> firstOrNull<OnlineMessageSource.Incoming>()
OnlineMessageSource.Incoming.FromGroup -> firstOrNull<OnlineMessageSource.Incoming.FromGroup>()
OnlineMessageSource.Incoming.FromFriend -> firstOrNull<OnlineMessageSource.Incoming.FromFriend>()
OnlineMessageSource -> firstOrNull<OnlineMessageSource>()
XmlMessage -> firstOrNull<XmlMessage>() XmlMessage -> firstOrNull<XmlMessage>()
JsonMessage -> firstOrNull<JsonMessage>() JsonMessage -> firstOrNull<JsonMessage>()
RichMessage -> firstOrNull<RichMessage>() RichMessage -> firstOrNull<RichMessage>()

View File

@ -193,11 +193,13 @@ fun MessageChain.quote(): QuoteReply {
return QuoteReply(this.source as? OnlineMessageSource ?: error("only online messages can be quoted")) return QuoteReply(this.source as? OnlineMessageSource ?: error("only online messages can be quoted"))
} }
@JvmSynthetic
suspend inline fun MessageSource.recall() = bot.recall(this) suspend inline fun MessageSource.recall() = bot.recall(this)
/** /**
* 撤回这条消息 * 撤回这条消息
*/ */
@JvmSynthetic
inline fun MessageSource.recallIn( inline fun MessageSource.recallIn(
timeMillis: Long, timeMillis: Long,
coroutineContext: CoroutineContext = EmptyCoroutineContext coroutineContext: CoroutineContext = EmptyCoroutineContext
@ -247,8 +249,10 @@ inline val MessageChain.id: Int
inline val MessageChain.source: MessageSource inline val MessageChain.source: MessageSource
get() = this[MessageSource] get() = this[MessageSource]
@JvmSynthetic
suspend inline fun MessageChain.recall() = this.source.recall() suspend inline fun MessageChain.recall() = this.source.recall()
@JvmSynthetic
inline fun MessageChain.recallIn( inline fun MessageChain.recallIn(
millis: Long, millis: Long,
coroutineContext: CoroutineContext = EmptyCoroutineContext coroutineContext: CoroutineContext = EmptyCoroutineContext