mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-09 18:00:33 +08:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
84a3ea1d99
@ -12,6 +12,8 @@
|
|||||||
package net.mamoe.mirai.event
|
package net.mamoe.mirai.event
|
||||||
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.channels.Channel
|
||||||
|
import kotlinx.coroutines.channels.ReceiveChannel
|
||||||
import net.mamoe.mirai.Bot
|
import net.mamoe.mirai.Bot
|
||||||
import net.mamoe.mirai.contact.isAdministrator
|
import net.mamoe.mirai.contact.isAdministrator
|
||||||
import net.mamoe.mirai.contact.isOperator
|
import net.mamoe.mirai.contact.isOperator
|
||||||
@ -125,6 +127,17 @@ inline fun <R> Bot.subscribeFriendMessages(crossinline listeners: MessageSubscri
|
|||||||
}.run(listeners)
|
}.run(listeners)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回一个指定事件的接收通道
|
||||||
|
*/
|
||||||
|
inline fun <reified E : Event> Bot.incoming(): ReceiveChannel<E> {
|
||||||
|
return Channel<E>(8).apply {
|
||||||
|
subscribeAlways<E> {
|
||||||
|
send(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 消息事件的处理器.
|
* 消息事件的处理器.
|
||||||
|
Loading…
Reference in New Issue
Block a user