Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/simple-robot/simbot-component-kritor
一个对Kritor协议作为客户端进行实现的 Simple Robot 组件库,Java 友好、异步高效~ 🐱🐱🐱
https://github.com/simple-robot/simbot-component-kritor
kritor simbot simbot-component
Last synced: 26 days ago
JSON representation
一个对Kritor协议作为客户端进行实现的 Simple Robot 组件库,Java 友好、异步高效~ 🐱🐱🐱
- Host: GitHub
- URL: https://github.com/simple-robot/simbot-component-kritor
- Owner: simple-robot
- License: lgpl-3.0
- Created: 2024-03-21T11:43:14.000Z (10 months ago)
- Default Branch: master
- Last Pushed: 2024-04-10T10:06:55.000Z (9 months ago)
- Last Synced: 2024-04-10T11:26:32.576Z (9 months ago)
- Topics: kritor, simbot, simbot-component
- Language: Kotlin
- Homepage:
- Size: 325 KB
- Stars: 3
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: COPYING
Awesome Lists containing this project
README
Simple Robot Kritor 组件是一个将
[Kritor](https://github.com/KarinJS/kritor)
协议在
[Simple Robot](http://github.com/simple-robot/simpler-robot) 标准API下实现的组件库,
并由此提供simbot中的各项能力。> [!caution]
> WIP now.## 使用
## 文档
## Examples
使用simbot核心库
```Kotlin
val application = launchSimpleApplication {
useKritor() // 安装使用Kritor组件库
}application.kritorBots {
// 注册bot并启动
retister(account = "", ticket = "") {
// config...
}.also { it.start() }
}// 注册事件处理器
application.listeners {
// 处理事件 ChatGroupMessageEvent
// 这是simbot API定义的泛用类型
process {
// ...
}// 指定处理 Kritor 组件内定义的各事件类型
// 比如此处的 Kritor 群消息事件
// Tips: KritorGroupMessageEvent 继承实现 ChatGroupMessageEvent
process { event ->
// 基于事件回复消息
event.reply("Hello, ")
// 基于 Group 实例发送消息
event.content().send(Text { "World!" })
}
}
```使用Spring Boot starter
配置信息:
```json
{
"component": "simbot.kritor",
"auth": {
"account": "",
"ticket": "",
"channel": {
"type": "address",
"name": "localhost",
"port": 8080
}
},
"config": {
}
}
``````Kotlin
@SpringBootApplication
@EnableSimbot // 启动simbot
class MainApp// 默认配置下,simbot会自动扫描并加载配置的bot信息,
// 并默认地自动启动它们fun main(args: Array) {
runApplication(*args)
}/** 一些事件处理器的载体 */
@Component
class MyHandler {
/** 监听处理 kritor 的群消息事件 */
@Listener
suspend fun onMessage(event: KritorGroupMessageEvent) {
// 基于事件回复消息
event.reply("Hello, ")
// 基于 Group 实例发送消息
event.content().send(Text { "World!" })
}
}
```