
High-performance asynchronous event scheduling framework for Bot applications. Features include a unified asynchronous API, component-driven functionality, and support for various Bot application platforms like KOOK and QQ.
Simple Robot 是一个基于Kotlin协程
的Kotlin多平台
Bot风格高性能异步事件调度框架(下文简称simbot),
异步高效、Java友好~
simbot提供统一的异步API和易用的风格设计,可以协助你更快速高效的编写Bot风格的事件调度应用。 主要应用于对接各种类型的Bot应用平台/框架,并提供部分组件库实现。
[!note] 自 5.0 版本起,所有由我们团队维护且稳定的组件,均合并至当前核心仓库一同维护。
simbot的平台功能由组件驱动,安装不同的组件库来获得不同的功能支持。
举个例子,在simbot中使用 KOOK 和 QQ 组件:
suspend fun main() {
launchSimpleApplication { config() }
.joinWith { module() }
}
fun ApplicationFactoryConfigurer<*, *, *>.config() {
// 安装 KOOK 和 QQ 组件
useKook()
useQQGuild()
}
/**
* 对已经构建完成的 `Application` 进行配置于应用
*/
suspend fun Application.module() {
registerBots()
registerListeners()
}
/**
* 注册所需的bot
*/
suspend fun Application.registerBots() {
// ... 注册kook bot,并在此之后可处理到kook的相关事件
kookBots {
register(...) { ... }.start()
}
// ... 注册QQ频道bot,并在此之后可处理到QQ频道的相关事件
qqGuildBots {
register(...) { ... }.start()
}
}
fun Application.registerListeners() {
listeners {
// 注册一个事件处理器
// ChatChannelMessageEvent 是由simbot API定义的泛用类型,代表所有子频道消息事件
// 其中就包括QQ频道的公域消息事件, 或者KOOK的频道消息事件
listen<ChatChannelMessageEvent> {
println("context: $this")
println("context.event: $event")
// 返回事件处理结果
EventResult.empty()
}
// 再注册一个事件处理器
// 明确监听QQ频道的公域消息事件
// 使用 process 不需要返回值
process<QGAtMessageCreateEvent> {
println("context: $this")
println("context.event: $event")
}
// 再注册一个事件处理器
// 明确监听KOOK的频道消息事件
// 使用 process 不需要返回值
process<KookChannelMessageEvent> {
println("context: $this")
println("context.event: $event")
}
}
}为我们点亮一个 ✨star🌟 便是能够给予我们继续走下去的最大动力与支持!
感谢 Jetbrains 为团队提供的免费授权,也希望大家能够支持 Jetbrains 及其产品,支持正版。
powered by Star History
Simple Robot 使用 LGPLv3 协议开源。
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Lesser GNU General Public License for more details.
You should have received a copy of the Lesser GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Simple Robot 是一个基于Kotlin协程
的Kotlin多平台
Bot风格高性能异步事件调度框架(下文简称simbot),
异步高效、Java友好~
simbot提供统一的异步API和易用的风格设计,可以协助你更快速高效的编写Bot风格的事件调度应用。 主要应用于对接各种类型的Bot应用平台/框架,并提供部分组件库实现。
[!note] 自 5.0 版本起,所有由我们团队维护且稳定的组件,均合并至当前核心仓库一同维护。
simbot的平台功能由组件驱动,安装不同的组件库来获得不同的功能支持。
举个例子,在simbot中使用 KOOK 和 QQ 组件:
suspend fun main() {
launchSimpleApplication { config() }
.joinWith { module() }
}
fun ApplicationFactoryConfigurer<*, *, *>.config() {
// 安装 KOOK 和 QQ 组件
useKook()
useQQGuild()
}
/**
* 对已经构建完成的 `Application` 进行配置于应用
*/
suspend fun Application.module() {
registerBots()
registerListeners()
}
/**
* 注册所需的bot
*/
suspend fun Application.registerBots() {
// ... 注册kook bot,并在此之后可处理到kook的相关事件
kookBots {
register(...) { ... }.start()
}
// ... 注册QQ频道bot,并在此之后可处理到QQ频道的相关事件
qqGuildBots {
register(...) { ... }.start()
}
}
fun Application.registerListeners() {
listeners {
// 注册一个事件处理器
// ChatChannelMessageEvent 是由simbot API定义的泛用类型,代表所有子频道消息事件
// 其中就包括QQ频道的公域消息事件, 或者KOOK的频道消息事件
listen<ChatChannelMessageEvent> {
println("context: $this")
println("context.event: $event")
// 返回事件处理结果
EventResult.empty()
}
// 再注册一个事件处理器
// 明确监听QQ频道的公域消息事件
// 使用 process 不需要返回值
process<QGAtMessageCreateEvent> {
println("context: $this")
println("context.event: $event")
}
// 再注册一个事件处理器
// 明确监听KOOK的频道消息事件
// 使用 process 不需要返回值
process<KookChannelMessageEvent> {
println("context: $this")
println("context.event: $event")
}
}
}为我们点亮一个 ✨star🌟 便是能够给予我们继续走下去的最大动力与支持!
感谢 Jetbrains 为团队提供的免费授权,也希望大家能够支持 Jetbrains 及其产品,支持正版。
powered by Star History
Simple Robot 使用 LGPLv3 协议开源。
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Lesser GNU General Public License for more details.
You should have received a copy of the Lesser GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.