KookBot

interface KookBot : CoroutineScope, LoggerContainer

Kook Bot对应的bot类型。

KookBot 提供标准定义,但是不实现 simple-robot-api 中的 love.forte.simbot.Bot 接口。

Author

ForteScarlet

Types

Link copied to clipboard
interface Client

Bot内部持有的连接信息。

Link copied to clipboard
interface Ticket

当前bot所使用的部分权限"票据"。

Functions

Link copied to clipboard
abstract suspend fun cancel(reason: Throwable? = null)

终止此bot并关闭所有连接。

Link copied to clipboard
abstract suspend fun join()

等待直到当前bot被取消。

Link copied to clipboard
abstract suspend fun me(): Me

查询bot当前信息。

Link copied to clipboard
abstract suspend fun offline()

让 bot 下线。

Link copied to clipboard
abstract fun preProcessor(processor: suspend Signal.Event.(decoder: Json, decoded: () -> Event<*>) -> Unit)

添加一个事件的前置处理器。

Link copied to clipboard
@Api4J
open fun process(processor: (rawEvent: Signal.Event, decoder: Json, decoded: () -> Event<*>) -> Unit)
@Api4J
open fun <EX : Event.Extra, E : Event<EX>> process(eventParser: EventParser<EX, E>, processor: (E) -> Unit)

process for java

Link copied to clipboard
abstract fun processor(processor: suspend Signal.Event.(decoder: Json, decoded: () -> Event<*>) -> Unit)

添加一个事件处理器。所有事件处理器会在每次触发的时候异步的按照添加顺序依次进行处理。

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

启动此bot的连接。

Properties

Link copied to clipboard

当前bot所使用的配置类。

Link copied to clipboard
abstract override val coroutineContext: CoroutineContext
Link copied to clipboard
abstract val httpClient: HttpClient

当前bot所使用的 HttpClient 实例。

Link copied to clipboard
abstract val isStarted: Boolean

此bot是否启动过了。

Link copied to clipboard
abstract override val logger: Logger
Link copied to clipboard
abstract val ticket: KookBot.Ticket

当前bot的票据信息。

Extensions

Link copied to clipboard
inline fun KookBot.processor(eventType: Event.Type, extraType: String, crossinline block: suspend Signal.Event.(decoder: Json, decoded: () -> Any) -> Unit)
inline fun KookBot.processor(eventType: Event.Type, extraType: Event.Type?, crossinline block: suspend Signal.Event.(decoder: Json, decoded: () -> Any) -> Unit)

提供一个事件类型, 并且可选的提供一个extra的子类型,监听这个事件。

inline fun <EX : Event.Extra, E : Event<EX>> KookBot.processor(eventParser: EventParser<EX, E>, crossinline block: suspend (E) -> Unit)

提供一个 EventParser 进行事件验证并在验证通过时进行事件处理。

inline fun <EX : Event.Extra, E : Event<EX>> KookBot.processor(eventDefinition: KookEventParserDefinition<EX, E>, crossinline block: suspend (E) -> Unit)

提供一个 KookEventParserDefinition 进行事件验证并在验证通过时进行事件处理。

Link copied to clipboard
inline fun <EX : Event.Extra, E : Event<EX>> KookBot.processorExcludeSelf(eventParser: EventParser<EX, E>, crossinline block: suspend (E) -> Unit)

提供一个 EventParser 进行事件验证并在验证通过时进行事件处理。

inline fun <EX : Event.Extra, E : Event<EX>> KookBot.processorExcludeSelf(eventDefinition: KookEventParserDefinition<EX, E>, crossinline block: suspend (E) -> Unit)

提供一个 KookEventParserDefinition 进行事件验证并在验证通过时进行事件处理。

Link copied to clipboard
inline suspend fun KookBot.request(api: KookApiRequest<*>): ApiResult

通过指定Bot,利用其token和client发起请求并得到对应的ApiResult

Link copied to clipboard

通过指定Bot,利用其token和client发起请求并得到对应的ApiResult

Link copied to clipboard
inline suspend fun <T> KookBot.requestData(api: KookApiRequest<T>): T

通过指定Bot,利用其token和client发起请求并得到对应的data响应值。

Link copied to clipboard

通过指定Bot,利用其token和client发起请求并得到对应的data响应值。