BotManager

Bot 管理器。 BotManager 应当是 获取、注册 Bot 的唯一公开途径, 所有 BotManager 均由 OriginBotManager 进行管理。

BotManager 实现 Survivable, 其存活周期与 Bot 无关。

事件提供者

BotManager 是一种的 EventProvider 实现,可用于安装在 love.forte.simbot.application.Application 环境中。

Author

ForteScarlet

See also

Constructors

Link copied to clipboard

Functions

Link copied to clipboard
abstract fun all(): List<B>

获取当前管理器下的所有BOT列表。

Link copied to clipboard

使当前 manager 脱离 OriginBotManager 的管理。

Link copied to clipboard
open suspend override fun cancel(reason: Throwable?): Boolean

执行关闭操作。 doCancel 为当前manager的自定义管理,当前manager关闭后,将会从 OriginBotManager 剔除自己。

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun delay(duration: JavaDuration, runnable: Runnable): DelayableCompletableFuture<Void?>

延时 duration 时间后执行回调函数 runnable,得到一个 DelayableCompletableFuture

open fun delay(millis: Long, runnable: Runnable): DelayableCompletableFuture<Void?>

延迟 millis 毫秒后执行 runnable,得到一个 DelayableCompletableFuture

open fun delay(time: Long, timeUnit: TimeUnit, runnable: Runnable): DelayableCompletableFuture<Void?>

延迟时间单位为 timeUnittime 时长后执行 runnable,得到一个 DelayableCompletableFuture

Link copied to clipboard

延迟 duration 时间后,执行 supplier, 并将 supplier 得到结果通过得到的 DelayableCompletableFuture 向下传递。

open fun <V> delayAndCompute(millis: Long, supplier: Supplier<V>): DelayableCompletableFuture<V>

延迟 millis 毫秒的时长后执行 supplier, 并将 supplier 得到结果通过得到的 DelayableCompletableFuture 向下传递。

open fun <V> delayAndCompute(time: Long, timeUnit: TimeUnit, supplier: Supplier<V>): DelayableCompletableFuture<V>

延迟时间单位为 timeUnittime 时长后执行 supplier, 并将 supplier 得到结果通过得到的 DelayableCompletableFuture 向下传递。

Link copied to clipboard
abstract operator fun get(id: ID): B?

根据Bot的ID获取一个已经注册过的 Bot

Link copied to clipboard
abstract fun invokeOnCompletion(handler: CompletionHandler)

当完成(或被cancel)时执行一段处理。

Link copied to clipboard
abstract suspend fun join()

挂起, 直到当前实例被 cancel 或完成.

Link copied to clipboard
abstract override fun register(verifyInfo: BotVerifyInfo): Bot

通过 BotVerifyInfo 注册并管理一个 Bot.

Link copied to clipboard
abstract suspend fun start(): Boolean

启动操作.

Link copied to clipboard
open fun waiting()

阻塞当前线程并等待 join 的挂起结束。

Properties

Link copied to clipboard
abstract val component: Component

获取当前内容所属组件。

Link copied to clipboard
Link copied to clipboard
abstract val isActive: Boolean

是否正在运行,即启动后尚未关闭。

Link copied to clipboard
abstract val isCancelled: Boolean

是否已经被取消。

Link copied to clipboard
abstract val isStarted: Boolean

是否已经启动过了。

Extensions

Link copied to clipboard
fun <A : Application> CoroutineScope.applicationLauncher(create: suspend () -> A): ApplicationLauncher<A>

通过一个协程作用域并提供构建函数来得到一个 ApplicationLauncher 实例。

Link copied to clipboard
inline fun <T> CoroutineScope.effectedFlowItems(crossinline block: suspend FlowCollector<T>.() -> Unit): Items<T>

以构建 Flow 的方式构建 Items.

Link copied to clipboard
inline fun <T> CoroutineScope.effectedItemsByFlow(crossinline flowFactory: () -> Flow<T>): Items<T>

提供 CoroutineScope 和构建 Flow 的函数 flowFactory 来构建 Items.

Link copied to clipboard
inline fun <T> CoroutineScope.flowItems(crossinline block: suspend FlowCollector<T>.(Items.PreprocessingProperties) -> Unit): Items<T>

以构建 Flow 的方式构建 Items.

Link copied to clipboard
inline fun <T> CoroutineScope.itemsByFlow(crossinline flowFactory: (Items.PreprocessingProperties) -> Flow<T>): Items<T>

提供 CoroutineScope 和构建 Flow 的函数 flowFactory 来构建 Items.

Link copied to clipboard
fun <T> CoroutineScope.lazyValue(init: Boolean = false, initializer: suspend () -> T): LazyValue<T>
Link copied to clipboard
inline fun <T> CoroutineScope.produceItems(context: CoroutineContext = EmptyCoroutineContext, capacity: Int = 0, crossinline block: suspend ProducerScope<T>.(Items.PreprocessingProperties) -> Unit): Items<T>

通过 produce 构建 ChannelIterator 来得到一个 Items 实例。