diff --git a/component/component-ding/pom.xml b/component/component-ding/pom.xml index 2560f85bc..a76995ca0 100644 --- a/component/component-ding/pom.xml +++ b/component/component-ding/pom.xml @@ -19,7 +19,7 @@ component-parent love.forte.simple-robot - 2.3.0-BETA.6 + 2.3.0 ../pom.xml 4.0.0 diff --git a/component/component-kaiheila-parent/README.md b/component/component-kaiheila-parent/README.md index edc3a4c55..2cbd5d4e4 100644 --- a/component/component-kaiheila-parent/README.md +++ b/component/component-kaiheila-parent/README.md @@ -77,6 +77,13 @@ 标准的开黑啦-simbot组件模块,基于上述其他模块以外,整合 [simbot-core](../../UPDATE.MD) 并实现完整的simbot功能,面向bot应用开发者。 +## ⚠️ 注意 +目前的v3-api模块较为完整可用,其他模块在 `simbot-3.x` 问世之前将不会大幅度更新。 +且在 `simbot-3.x` 问世前,开黑啦组件下的各模块不会发布**正式版本**。 + +不过对于例如 `v3-api` 这种与simbot无关的api模块,你依然可以使用,并欢迎提供反馈与建议。 + +
## 使用 @@ -95,100 +102,32 @@ TODO -## Demo - -TODO - +## 简单示例 +### API-V3 +API组件中,提供了针对于官方的大部分客户端请求API的基础封装,比如: +```kotlin + @Test + fun listTest() = runBlocking { + val guildId = "6865507942900765" // GuildApiTest().guildList().items[0].id + val client = HttpClient() // ktor client + val token = "token" -## 极简示例 + val data: ListResp = ChannelListReq(guildId).doRequest(V3, client, token) -文档-快速开始:https://www.yuque.com/simpler-robot/simpler-robot-doc/qeyorq + println(data) + println("-0-") -### 监听消息 - -```java -@Beans -public class TestListener { - /** 发送一句“我收到了”,并再复读收到的所有消息 */ - @OnPrivate - public void listen(PrivateMsg msg, MsgSender sender) { - sender.SENDER.sendPrivateMsg(msg, "我收到了"); - sender.SENDER.sendPrivateMsg(msg, msg.getMsgContent()); - } -} -``` - -### 监听并筛选消息 - -```java -@Beans -public class TestListener { - /** 监听群里的 'hi! simbot' 消息并作出回应 */ - @OnGroup - @Filter("hi! simbot") - public void listenGroup(GroupMsg msg, MsgSender sender) { - // 获取发消息的人的账号 - String accountCode = m.getAccountInfo().getAccountCode(); - // 准备at这个人的CatCode - String at = CatCodeUtil.INSTANCE.getStringTemplate().at(accountCode); - // 发送消息 - sender.SENDER.sendGroupMsg(m, at + " 我在哦"); - } -} + data.forEach { it: ChannelInfo -> + println(it) + } + } ``` +其中,`ChannelListReq` 即为对于 `/channel/list` 接口的封装。 +所有的api请求实例均为此类的命名方式。 -或 - -```java -@Beans -public class TestListener { - /** 通过依赖注入得到消息构建器工厂。 */ - @Depend - private MessageContentBuilderFactory builderFactory; - - /** 监听群里的 'hi! simbot' 消息并作出回应 */ - @OnGroup - @Filter("hi! simbot") - public void listenGroup(GroupMsg msg, MsgSender sender){ - // 获取发消息的人的账号 - String accountCode = msg.getAccountInfo().getAccountCode(); - // 获取消息构建器 - MessageContentBuilder builder = builderFactory.getMessageContentBuilder(); - // 构建消息实例 - MessageContent msgContent = builder.at(accountCode).text(" 我在哦").build(); - // 发送消息 - sender.SENDER.sendGroupMsg(msg, msgContent); - } -} -``` - - -## 协助我 -- 你可以通过 [pr](https://github.com/ForteScarlet/simpler-robot/pulls "pull request") 为项目代码作出贡献。 -- 你可以通过 [issue](https://github.com/ForteScarlet/simpler-robot/issues "issues") 提出一个建议或者反馈一个问题。 -- 你可以通过 [讨论区](https://github.com/ForteScarlet/simpler-robot/discussions "discussions") 与其他人或者simbot开发团队相互友好交流。 -- 如果你通过此项目创建了一个很酷的项目,欢迎通过 [issue](https://github.com/ForteScarlet/simpler-robot/issues) 、[讨论区](https://github.com/ForteScarlet/simpler-robot/discussions) 、[QQ群寻找群主](https://jq.qq.com/?_wv=1027&k=1Lopqryf) - 等方式联系团队开发人员,并将你酷酷的项目展示在作品展示区。 - - -## 捐助我 -如果你喜欢这个项目,不妨试着 [捐助](https://www.yuque.com/docs/share/43264d27-99a7-4287-97c0-b387f5b0947e) 一下我们,十分感谢。 - - -## 特别鸣谢 - -[![](https://logonoid.com/images/thumbs/intellij-idea-logo.png "IntelliJ IDEA")](https://www.jetbrains.com/idea/) - -感谢 [jetbrains](https://www.jetbrains.com/ "jetbrains") 为团队提供的免费 [IntelliJ IDEA](https://www.jetbrains.com/idea/ "IntelliJ IDEA") 授权,也希望大家能够支持IDEA,支持正版。 - -***** - -[![](../../logo/CatCodeLogo@0,1x.png "CatCode")](https://github.com/ForteScarlet/CatCode) - -感谢 [猫猫码](https://github.com/ForteScarlet/CatCode "CatCode") 为本项目提供支持并绘制项目LOGO。 - - +在得到 `xxxReq` 实例后,可以通过顶层函数 `xxxReq.doRequest(client, token)` 发送api请求,并得到响应值。 +列表类型的响应值类型如上面所示,是一个 `ListResp` 实例。其中,`DATA` 便是每个元素的实例,`SORT` 则为排序参数的响应(如果有的话)。 diff --git a/component/component-kaiheila-parent/kaiheila-api-v3/src/test/java/love/test/channel/ChannelListTest.kt b/component/component-kaiheila-parent/kaiheila-api-v3/src/test/java/love/test/channel/ChannelListTest.kt index 3929f11d1..2f4b2adac 100644 --- a/component/component-kaiheila-parent/kaiheila-api-v3/src/test/java/love/test/channel/ChannelListTest.kt +++ b/component/component-kaiheila-parent/kaiheila-api-v3/src/test/java/love/test/channel/ChannelListTest.kt @@ -1,50 +1,55 @@ -// /* -// * -// * * Copyright (c) 2021. ForteScarlet All rights reserved. -// * * Project simple-robot -// * * File MiraiAvatar.kt -// * * -// * * You can contact the author through the following channels: -// * * github https://github.com/ForteScarlet -// * * gitee https://gitee.com/ForteScarlet -// * * email ForteScarlet@163.com -// * * QQ 1149159218 -// * -// */ -// -// package love.test.channel -// -// import kotlinx.coroutines.runBlocking -// import love.forte.simbot.kaiheila.api.doRequest -// import love.forte.simbot.kaiheila.api.v3.V3 -// import love.forte.simbot.kaiheila.api.v3.channel.ChannelListReq -// import love.test.GatewayApiConstant -// import love.test.client -// import kotlin.test.Test -// -// -// /** -// * -// * @author ForteScarlet -// */ -// class ChannelListTest { -// -// -// @Test -// fun listTest() = runBlocking { -// val guildId = "6865507942900765" // GuildApiTest().guildList().items[0].id -// -// val data = ChannelListReq(guildId).doRequest(V3, client, GatewayApiConstant.token).data -// -// println(data) -// -// println("-0-") -// -// data.forEach { -// println(it) -// } -// -// -// } -// -// } \ No newline at end of file +/* + * + * * Copyright (c) 2021. ForteScarlet All rights reserved. + * * Project simple-robot + * * File MiraiAvatar.kt + * * + * * You can contact the author through the following channels: + * * github https://github.com/ForteScarlet + * * gitee https://gitee.com/ForteScarlet + * * email ForteScarlet@163.com + * * QQ 1149159218 + * + */ + +package love.test.channel + +import io.ktor.client.* +import kotlinx.coroutines.runBlocking +import love.forte.simbot.kaiheila.api.ApiData +import love.forte.simbot.kaiheila.api.ListResp +import love.forte.simbot.kaiheila.api.doRequest +import love.forte.simbot.kaiheila.api.v3.V3 +import love.forte.simbot.kaiheila.api.v3.channel.ChannelInfo +import love.forte.simbot.kaiheila.api.v3.channel.ChannelListReq +import kotlin.test.Test + + +/** + * + * @author ForteScarlet + */ +class ChannelListTest { + + + @Test + fun listTest() = runBlocking { + val guildId = "6865507942900765" // GuildApiTest().guildList().items[0].id + + val client = HttpClient() // ktor client + val token = "token" + + val data: ListResp = ChannelListReq(guildId).doRequest(V3, client, token) + + println(data) + + println("-0-") + + data.forEach { it: ChannelInfo -> + println(it) + } + + + } + +} \ No newline at end of file diff --git a/component/component-kaiheila-parent/pom.xml b/component/component-kaiheila-parent/pom.xml index e7e72cedf..c5f637d60 100644 --- a/component/component-kaiheila-parent/pom.xml +++ b/component/component-kaiheila-parent/pom.xml @@ -5,7 +5,7 @@ component-parent love.forte.simple-robot - 2.3.0-BETA.6 + 2.3.0 ../pom.xml diff --git a/component/component-lovelycat-httpapi/pom.xml b/component/component-lovelycat-httpapi/pom.xml index 4f9a979a2..cc747f651 100644 --- a/component/component-lovelycat-httpapi/pom.xml +++ b/component/component-lovelycat-httpapi/pom.xml @@ -5,7 +5,7 @@ component-parent love.forte.simple-robot - 2.3.0-BETA.6 + 2.3.0 ../pom.xml 4.0.0 diff --git a/component/component-mirai/pom.xml b/component/component-mirai/pom.xml index e1ff53d78..e7c86f432 100644 --- a/component/component-mirai/pom.xml +++ b/component/component-mirai/pom.xml @@ -5,7 +5,7 @@ love.forte.simple-robot component-parent - 2.3.0-BETA.6 + 2.3.0 ../pom.xml 4.0.0 diff --git a/component/pom.xml b/component/pom.xml index 06c4b181f..1aca3bb9d 100644 --- a/component/pom.xml +++ b/component/pom.xml @@ -5,7 +5,7 @@ project love.forte.simple-robot - 2.3.0-BETA.6 + 2.3.0 ../pom.xml 4.0.0 diff --git a/core-api/api/pom.xml b/core-api/api/pom.xml index 569abed0a..dd1ed35a9 100644 --- a/core-api/api/pom.xml +++ b/core-api/api/pom.xml @@ -5,7 +5,7 @@ project love.forte.simple-robot - 2.3.0-BETA.6 + 2.3.0 ../../pom.xml 4.0.0 diff --git a/core-api/core/pom.xml b/core-api/core/pom.xml index 06f734d04..5d123fc92 100644 --- a/core-api/core/pom.xml +++ b/core-api/core/pom.xml @@ -5,7 +5,7 @@ project love.forte.simple-robot - 2.3.0-BETA.6 + 2.3.0 ../../pom.xml 4.0.0 diff --git a/http/client-core/pom.xml b/http/client-core/pom.xml index 4a4496485..b401ac40c 100644 --- a/http/client-core/pom.xml +++ b/http/client-core/pom.xml @@ -5,7 +5,7 @@ http-parent love.forte.simple-robot.http - 2.3.0-BETA.6 + 2.3.0 ../pom.xml 4.0.0 diff --git a/http/client-ktor/pom.xml b/http/client-ktor/pom.xml index 2dee79b58..e02759d79 100644 --- a/http/client-ktor/pom.xml +++ b/http/client-ktor/pom.xml @@ -5,7 +5,7 @@ http-parent love.forte.simple-robot.http - 2.3.0-BETA.6 + 2.3.0 ../pom.xml 4.0.0 diff --git a/http/client-restTemplate/pom.xml b/http/client-restTemplate/pom.xml index a2cffca81..38c2a32f1 100644 --- a/http/client-restTemplate/pom.xml +++ b/http/client-restTemplate/pom.xml @@ -6,7 +6,7 @@ http-parent love.forte.simple-robot.http - 2.3.0-BETA.6 + 2.3.0 ../pom.xml 4.0.0 diff --git a/http/pom.xml b/http/pom.xml index 796cf2b00..60ee7cb12 100644 --- a/http/pom.xml +++ b/http/pom.xml @@ -6,7 +6,7 @@ project love.forte.simple-robot - 2.3.0-BETA.6 + 2.3.0 ../pom.xml 4.0.0 diff --git a/parent/pom.xml b/parent/pom.xml index 01384cc8f..70f1c78d2 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -6,7 +6,7 @@ love.forte.simple-robot parent - 2.3.0-BETA.6 + 2.3.0 pom @@ -23,7 +23,7 @@ simple-robot是一个通用bot开发框架,以同一种灵活的标准来编写不同平台的bot应用。而simpler-robot便是simple-robot 2.x版本命名。 - 2.3.0-BETA.6 + 2.3.0 0.0.1-ALPHA.1 8 diff --git a/pom.xml b/pom.xml index f14c595be..50b71290d 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ love.forte.simple-robot parent - 2.3.0-BETA.6 + 2.3.0 ./parent/pom.xml diff --git a/serialization/json-core/pom.xml b/serialization/json-core/pom.xml index 1592c8f61..67bd83d93 100644 --- a/serialization/json-core/pom.xml +++ b/serialization/json-core/pom.xml @@ -5,7 +5,7 @@ serialization-parent love.forte.simple-robot.serialization - 2.3.0-BETA.6 + 2.3.0 ../pom.xml 4.0.0 diff --git a/serialization/json-fastjson/pom.xml b/serialization/json-fastjson/pom.xml index db3084fe6..c604cdaef 100644 --- a/serialization/json-fastjson/pom.xml +++ b/serialization/json-fastjson/pom.xml @@ -5,7 +5,7 @@ serialization-parent love.forte.simple-robot.serialization - 2.3.0-BETA.6 + 2.3.0 ../pom.xml 4.0.0 diff --git a/serialization/json-jackson/pom.xml b/serialization/json-jackson/pom.xml index 168950656..a84fa4008 100644 --- a/serialization/json-jackson/pom.xml +++ b/serialization/json-jackson/pom.xml @@ -5,7 +5,7 @@ serialization-parent love.forte.simple-robot.serialization - 2.3.0-BETA.6 + 2.3.0 ../pom.xml 4.0.0 diff --git a/serialization/json-moshi/pom.xml b/serialization/json-moshi/pom.xml index 7bbe8bfc3..22696735c 100644 --- a/serialization/json-moshi/pom.xml +++ b/serialization/json-moshi/pom.xml @@ -5,7 +5,7 @@ serialization-parent love.forte.simple-robot.serialization - 2.3.0-BETA.6 + 2.3.0 ../pom.xml 4.0.0 diff --git a/serialization/pom.xml b/serialization/pom.xml index 5cad97cbd..772fa9fcd 100644 --- a/serialization/pom.xml +++ b/serialization/pom.xml @@ -5,7 +5,7 @@ project love.forte.simple-robot - 2.3.0-BETA.6 + 2.3.0 ../pom.xml 4.0.0 diff --git a/simbot-x/plugin-core/pom.xml b/simbot-x/plugin-core/pom.xml index b1ba26991..9417de8fc 100644 --- a/simbot-x/plugin-core/pom.xml +++ b/simbot-x/plugin-core/pom.xml @@ -5,7 +5,7 @@ project love.forte.simple-robot - 2.3.0-BETA.6 + 2.3.0 ../../pom.xml 4.0.0 diff --git a/spring-boot-starter/component-lovelycat-httpapi-spring-boot-starter/pom.xml b/spring-boot-starter/component-lovelycat-httpapi-spring-boot-starter/pom.xml index 233299981..53a46519d 100644 --- a/spring-boot-starter/component-lovelycat-httpapi-spring-boot-starter/pom.xml +++ b/spring-boot-starter/component-lovelycat-httpapi-spring-boot-starter/pom.xml @@ -6,7 +6,7 @@ spring-boot-starter love.forte.simple-robot - 2.3.0-BETA.6 + 2.3.0 ../pom.xml 4.0.0 diff --git a/spring-boot-starter/component-mirai-spring-boot-starter/pom.xml b/spring-boot-starter/component-mirai-spring-boot-starter/pom.xml index a8f822fa7..1e898e097 100644 --- a/spring-boot-starter/component-mirai-spring-boot-starter/pom.xml +++ b/spring-boot-starter/component-mirai-spring-boot-starter/pom.xml @@ -5,7 +5,7 @@ spring-boot-starter love.forte.simple-robot - 2.3.0-BETA.6 + 2.3.0 ../pom.xml 4.0.0 diff --git a/spring-boot-starter/core-spring-boot-starter/pom.xml b/spring-boot-starter/core-spring-boot-starter/pom.xml index d94e42e12..786b7dbce 100644 --- a/spring-boot-starter/core-spring-boot-starter/pom.xml +++ b/spring-boot-starter/core-spring-boot-starter/pom.xml @@ -5,7 +5,7 @@ spring-boot-starter love.forte.simple-robot - 2.3.0-BETA.6 + 2.3.0 ../pom.xml 4.0.0 diff --git a/spring-boot-starter/pom.xml b/spring-boot-starter/pom.xml index 19a1dc994..f88eef2b4 100644 --- a/spring-boot-starter/pom.xml +++ b/spring-boot-starter/pom.xml @@ -5,7 +5,7 @@ project love.forte.simple-robot - 2.3.0-BETA.6 + 2.3.0 ../pom.xml 4.0.0 diff --git a/time-task/pom.xml b/time-task/pom.xml index e6c8c874a..bcaa215bc 100644 --- a/time-task/pom.xml +++ b/time-task/pom.xml @@ -5,7 +5,7 @@ project love.forte.simple-robot - 2.3.0-BETA.6 + 2.3.0 4.0.0 diff --git a/time-task/time-task-core/pom.xml b/time-task/time-task-core/pom.xml index bb0ffb1a4..ad1c32c8d 100644 --- a/time-task/time-task-core/pom.xml +++ b/time-task/time-task-core/pom.xml @@ -6,7 +6,7 @@ time-task-parent love.forte.simple-robot.time-task - 2.3.0-BETA.6 + 2.3.0 4.0.0 diff --git a/time-task/time-task-quartz/pom.xml b/time-task/time-task-quartz/pom.xml index e48d32379..f50ee93a4 100644 --- a/time-task/time-task-quartz/pom.xml +++ b/time-task/time-task-quartz/pom.xml @@ -5,7 +5,7 @@ time-task-parent love.forte.simple-robot.time-task - 2.3.0-BETA.6 + 2.3.0 4.0.0