mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-09 01:30:17 +08:00
Add unconditional nextMessage
This commit is contained in:
parent
fb25baa78d
commit
ec248c8dd3
@ -166,4 +166,21 @@ suspend inline fun <reified P : MessagePacket<*, *>> P.nextMessage(
|
||||
return subscribingGet<P, P>(timeoutMillis) {
|
||||
takeIf { this.isContextIdenticalWith(this@nextMessage) }?.takeIf { filter(it, it) }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 挂起当前协程, 等待下一条 [MessagePacket.sender] 和 [MessagePacket.subject] 与 [P] 相同的 [MessagePacket]
|
||||
*
|
||||
* 若 [filter] 抛出了一个异常, 本函数会立即抛出这个异常.
|
||||
*
|
||||
* @param timeoutMillis 超时. 单位为毫秒. `-1` 为不限制
|
||||
*
|
||||
* @see subscribingGetAsync 本函数的异步版本
|
||||
*/
|
||||
suspend inline fun <reified P : MessagePacket<*, *>> P.nextMessage(
|
||||
timeoutMillis: Long = -1
|
||||
): P {
|
||||
return subscribingGet<P, P>(timeoutMillis) {
|
||||
takeIf { this.isContextIdenticalWith(this@nextMessage) }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user