mirror of
https://github.com/mamoe/mirai.git
synced 2025-02-23 10:20:14 +08:00
Improve MessagePacket<*, *>.nextMessage
This commit is contained in:
parent
06381e8ba2
commit
2b7b8fa6c1
@ -162,10 +162,10 @@ fun MessagePacket<*, *>.isContextIdenticalWith(another: MessagePacket<*, *>): Bo
|
||||
suspend inline fun <reified P : MessagePacket<*, *>> P.nextMessage(
|
||||
timeoutMillis: Long = -1,
|
||||
crossinline filter: P.(P) -> Boolean
|
||||
): P {
|
||||
): MessageChain {
|
||||
return subscribingGet<P, P>(timeoutMillis) {
|
||||
takeIf { this.isContextIdenticalWith(this@nextMessage) }?.takeIf { filter(it, it) }
|
||||
}
|
||||
}.message
|
||||
}
|
||||
|
||||
/**
|
||||
@ -179,8 +179,8 @@ suspend inline fun <reified P : MessagePacket<*, *>> P.nextMessage(
|
||||
*/
|
||||
suspend inline fun <reified P : MessagePacket<*, *>> P.nextMessage(
|
||||
timeoutMillis: Long = -1
|
||||
): P {
|
||||
): MessageChain {
|
||||
return subscribingGet<P, P>(timeoutMillis) {
|
||||
takeIf { this.isContextIdenticalWith(this@nextMessage) }
|
||||
}
|
||||
}.message
|
||||
}
|
Loading…
Reference in New Issue
Block a user