diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml new file mode 100644 index 0000000..f4c1b19 --- /dev/null +++ b/.github/workflows/gradle.yml @@ -0,0 +1,35 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle + +name: Java CI with Gradle + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master", "develop" ] + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'liberica' + - name: Build with Gradle + uses: gradle/gradle-build-action@v2 + with: + arguments: build + gradle-version: 8.1 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 5ce097c..c2065bc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,37 @@ +HELP.md .gradle +build/ +!gradle/wrapper/gradle-wrapper.jar +!**/src/main/**/build/ +!**/src/test/**/build/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### IntelliJ IDEA ### .idea -**/build -test/src/main/resources/application.properties -test/src/test/resources/application.properties \ No newline at end of file +*.iws +*.iml +*.ipr +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ diff --git a/README.md b/README.md index 4008ed7..105e5f2 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,17 @@ # kook-spring-boot-stater -![OpenJDK](https://img.shields.io/badge/OpenJDK-8-purple?style=for-the-badge&logo=OpenJDK) -![Maven-Central](https://img.shields.io/maven-central/v/cn.enaium/kook-spring-boot-starter?style=for-the-badge) +![OpenJDK](https://img.shields.io/badge/OpenJDK-17-white?style=flat-square&logo=OpenJDK) +![SpringBoot](https://img.shields.io/badge/SpringBoot-3-green?style=flat-square&logo=SpringBoot) +![Maven-Central](https://img.shields.io/maven-central/v/cn.enaium/kook-spring-boot-starter?style=flat-square) +![JitPack](https://img.shields.io/jitpack/version/com.github.Enaium/kook-spring-boot-starter?style=flat-square) +![GitHub](https://img.shields.io/github/license/enaium/kook-spring-boot-starter?style=flat-square) -支持了所有的HttpAPI和Websocket事件,可以在`test`里查看例子 +支持了所有的Http接口和Websocket事件,可以在`kookstarter-sample`里查看例子 最新版本以maven仓库中版本为准 +## 依赖 + ```xml cn.enaium @@ -19,4 +24,10 @@ implementation 'cn.enaium:kook-spring-boot-starter:最新版本' ``` +```kts +implementation("cn.enaium:kook-spring-boot-starter:最新版本") +``` + +本项目使用了`webflux`也需要添加`webflux`依赖 + 提交pr时请提交到`develop`而不是`master` \ No newline at end of file diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 6e4d8e5..0000000 --- a/build.gradle +++ /dev/null @@ -1,5 +0,0 @@ -allprojects { - repositories { - mavenCentral() - } -} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..71f3215 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,18 @@ +allprojects { + group = "cn.enaium" + version = "0.3.0" + + repositories { + mavenCentral() + } +} + +subprojects { + tasks.withType { + options.encoding = "UTF-8" + } + + tasks.withType { + options.encoding = "UTF-8" + } +} \ No newline at end of file diff --git a/core/build.gradle b/core/build.gradle deleted file mode 100644 index 3fe2581..0000000 --- a/core/build.gradle +++ /dev/null @@ -1,111 +0,0 @@ -plugins { - id 'org.springframework.boot' version '2.7.2' - id 'io.spring.dependency-management' version '1.0.12.RELEASE' - id 'maven-publish' - id 'signing' - id 'java' - id 'java-library' -} - -group 'cn.enaium' -version '0.2.1' -archivesBaseName = 'kook-spring-boot-starter' - -repositories { - mavenCentral() -} - -dependencies { - implementation 'org.springframework.boot:spring-boot-starter' - implementation 'org.springframework.boot:spring-boot-starter-websocket' - api 'com.konghq:unirest-java:3.13.11' - - annotationProcessor "org.springframework.boot:spring-boot-configuration-processor" - - testImplementation 'org.springframework.boot:spring-boot-starter-test' -} - -sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8 - -java { - withSourcesJar() - withJavadocJar() -} - -tasks.named("bootJar") { - enabled = false -} - -tasks.named("jar") { - archiveClassifier = '' -} - -tasks.withType(JavaCompile) { - options.encoding = "UTF-8" -} - -tasks.withType(Javadoc) { - options.encoding = "UTF-8" -} - -publishing { - repositories { - maven { - url "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" - credentials { - username ossrhUsername - password ossrhPassword - } - } - } - - publications { - mavenJava(MavenPublication) { - groupId project.group - artifactId archivesBaseName - version project.version - - from components.java - - versionMapping { - usage('java-api') { - fromResolutionOf('runtimeClasspath') - } - usage('java-runtime') { - fromResolutionResult() - } - } - - pom { - name = 'kook-spring-boot-starter' - description = 'KOOK机器人的spring-boot-starter' - url = 'https://github.com/Enaium/kook-spring-boot-starter/' - - licenses { - license { - name = 'The Apache License, Version 2.0' - url = 'https://www.apache.org/licenses/LICENSE-2.0.txt' - } - } - - developers { - developer { - id = 'enaium' - name = 'Enaium' - email = 'Enaium@outlook.com' - } - } - - scm { - connection = 'scm:git:https://github.com/Enaium/kook-spring-boot-starter.git' - developerConnection = 'scm:git:https://github.com/Enaium/kook-spring-boot-starter.git' - url = 'https://github.com/Enaium/kook-spring-boot-starter/' - } - } - } - } -} - -signing { - sign publishing.publications.mavenJava -} \ No newline at end of file diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/KookSpringBootStarter.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/KookSpringBootStarter.java deleted file mode 100644 index a2047b0..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/KookSpringBootStarter.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.enaium.kook.spring.boot.starter; - -import cn.enaium.kook.spring.boot.starter.connect.WebSocketClient; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.Banner; -import org.springframework.boot.CommandLineRunner; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Component; - -import java.io.PrintStream; - -/** - * @author Enaium - */ -@ComponentScan -public class KookSpringBootStarter { - - private final Logger logger = LogManager.getLogger(KookSpringBootStarter.class); - - @Autowired - private WebSocketClient webSocketClient; - - @Bean - private CommandLineRunner run() { - return args -> { - logger.info(" _ __ _ ____ _ _ "); - logger.info("| |/ /___ ___ | | __/ ___|| |_ __ _ _ __| |_ ___ _ __"); - logger.info("| ' // _ \\ / _ \\| |/ /\\___ \\| __/ _` | '__| __/ _ \\ '__|"); - logger.info("| . \\ (_) | (_) | < ___) | || (_| | | | || __/ | "); - logger.info("|_|\\_\\___/ \\___/|_|\\_\\|____/ \\__\\__,_|_| \\__\\___|_| "); - webSocketClient.start(); - }; - } -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/annotation/event/Event.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/annotation/event/Event.java deleted file mode 100644 index 8acf514..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/annotation/event/Event.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.annotation.event; - -import org.springframework.stereotype.Component; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * 表示这个方法是一个事件,类上必须添加{@link Register}注解 - * - * @author Enaium - * @since 0.1.0 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -@Component -public @interface Event { - /** - * EventData的泛型,由于Java的特性泛型编译后都被变成Object所有必须指定,也就是监听器 - * @return 监听器 - */ - Class value(); - /** - * @return 优先级, 越大优先级越高 - */ - int priority() default 0; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/annotation/event/Listener.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/annotation/event/Listener.java deleted file mode 100644 index a7c5218..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/annotation/event/Listener.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.annotation.event; - -import org.springframework.core.annotation.AliasFor; -import org.springframework.stereotype.Component; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * 在类上添加注解表示这个类是一个监听器 - *

- * 类必须继承{@link cn.enaium.kook.spring.boot.starter.model.sign.data.extra.SystemMessageExtra}类 - *

- * 或{@link cn.enaium.kook.spring.boot.starter.model.sign.data.extra.TextMessageExtra}类 - *

- * 必须在监听器类中声明一个静态变量,类型为{@link String},名称为TYPE - *

- * 比如 - *

{@code public static final String TYPE = "added_channel"; }
- * - * @author Enaium - * @since 0.1.0 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -@Component -public @interface Listener { -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/API.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/API.java deleted file mode 100644 index ef67faf..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/API.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.api; - -import java.util.Map; - -/** - * @author Enaium - */ -public class API { - private final Method method; - private final String path; - - private Map body; - - public API(Method method, String path) { - this.method = method; - this.path = path; - } - - public Method getMethod() { - return method; - } - - public String getPath() { - return path; - } - - public Map getBody() { - return body; - } - - public API setBody(Map body) { - this.body = body; - return this; - } - - public enum Method { - GET, POST, HEAD, OPTIONS, PUT, DELETE, TRACE - } -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/ChannelAPI.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/ChannelAPI.java deleted file mode 100644 index 048c31e..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/ChannelAPI.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.api; - -/** - * 频道相关接口 - * - * @author Enaium - * @since 0.1.0 - */ -public interface ChannelAPI { - /** - * 获取频道列表 - */ - API CHANNEL_LIST = new API(API.Method.GET, "channel/list"); - /** - * 获取频道详情 - */ - API CHANNEL_VIEW = new API(API.Method.GET, "channel/view"); - /** - * 创建频道 - */ - API CHANNEL_CREATE = new API(API.Method.POST, "channel/create"); - /** - * 编辑频道 - */ - API CHANNEL_UPDATE = new API(API.Method.POST, "channel/update"); - /** - * 删除频道 - */ - API CHANNEL_DELETE = new API(API.Method.POST, "channel/delete"); - /** - * 语音频道之间移动用户 - */ - API CHANNEL_MOVE_USER = new API(API.Method.POST, "channel/move-user"); - /** - * 获取频道角色权限详情 - */ - API CHANNEL_ROLE_INDEX = new API(API.Method.GET, "channel-role/index"); - /** - * 创建频道角色权限 - */ - API CHANNEL_ROLE_CREATE = new API(API.Method.POST, "channel-role/create"); - /** - * 更新频道角色权限 - */ - API CHANNEL_ROLE_UPDATE = new API(API.Method.POST, "channel-role/update"); - /** - * 删除频道角色权限 - */ - API CHANNEL_ROLE_DELETE = new API(API.Method.POST, "channel-role/delete"); -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/DirectMessageAPI.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/DirectMessageAPI.java deleted file mode 100644 index 88e8fd5..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/DirectMessageAPI.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.api; - -/** - * 用户私聊消息接口 - * - * @author Enaium - * @since 0.1.0 - */ -public interface DirectMessageAPI { - /** - * 获取私信聊天消息列表 - */ - API DIRECT_MESSAGE_LIST = new API(API.Method.GET,"direct-message/list"); - /** - * 发送私信聊天消息 - */ - API DIRECT_MESSAGE_CREATE = new API(API.Method.POST,"direct-message/create"); - /** - * 更新私信聊天消息 - */ - API DIRECT_MESSAGE_UPDATE = new API(API.Method.POST,"direct-message/update"); - /** - * 删除私信聊天消息 - */ - API DIRECT_MESSAGE_DELETE = new API(API.Method.POST,"direct-message/delete"); - /** - * 获取频道消息某回应的用户列表 - */ - API DIRECT_MESSAGE_REACTION_LIST = new API(API.Method.GET,"direct-message/reaction-list"); - /** - * 给某个消息添加回应 - */ - API DIRECT_MESSAGE_ADD_REACTION = new API(API.Method.POST,"direct-message/add-reaction"); - /** - * 删除消息的某个回应 - */ - API DIRECT_MESSAGE_DELETE_REACTION = new API(API.Method.POST,"direct-message/delete-reaction"); -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/GameAPI.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/GameAPI.java deleted file mode 100644 index 0a872e2..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/GameAPI.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.api; - -/** - * 用户动态相关接口 - * - * @author Enaium - * @since 0.1.0 - */ -public interface GameAPI { - /** - * 游戏列表 - */ - API GAME = new API(API.Method.GET, "game"); - /** - * 添加游戏 - */ - API GAME_CREATE = new API(API.Method.POST, "game/create"); - /** - * 更新游戏 - */ - API GAME_UPDATE = new API(API.Method.POST, "game/update"); - /** - * 删除游戏 - */ - API GAME_DELETE = new API(API.Method.POST, "game/delete"); - /** - * 添加游戏记录-开始玩 - */ - API GAME_ACTIVITY = new API(API.Method.POST, "game/activity"); - /** - * 删除游戏记录-结束玩 - */ - API GAME_DELETE_ACTIVITY = new API(API.Method.POST, "game/delete-activity"); -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/GuildAPI.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/GuildAPI.java deleted file mode 100644 index f6f28d9..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/GuildAPI.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.api; - -/** - * 服务器相关接口 - * - * @author Enaium - * @since 0.1.0 - */ -public interface GuildAPI { - /** - * 获取当前用户加入的服务器列表 - */ - API GUILD_LIST = new API(API.Method.GET, "guild/list"); - /** - * 获取服务器详情 - */ - API GUILD_VIEW = new API(API.Method.GET, "guild/view"); - /** - * 获取服务器中的用户列表 - */ - API GUILD_USER_LIST = new API(API.Method.GET, "guild/user-list"); - /** - * 修改服务器中用户的昵称 - */ - API GUILD_NICKNAME = new API(API.Method.POST, "guild/nickname"); - /** - * 离开服务器 - */ - API GUILD_LEAVE = new API(API.Method.POST, "guild/leave"); - /** - * 踢出服务器 - */ - API GUILD_KICKOUT = new API(API.Method.POST, "guild/kickout"); - /** - * 服务器静音闭麦列表 - */ - API GUILD_MUTE_LIST = new API(API.Method.GET, "guild-mute/list"); - /** - * 添加服务器静音或闭麦 - */ - API GUILD_MUTE_CREATE = new API(API.Method.POST, "guild-mute/create"); - /** - * 删除服务器静音或闭麦 - */ - API GUILD_MUTE_DELETE = new API(API.Method.POST, "guild-mute/delete"); - -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/GuildRoleAPI.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/GuildRoleAPI.java deleted file mode 100644 index ca2fda6..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/GuildRoleAPI.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.api; - -/** - * 服务器角色权限相关接口 - * - * @author Enaium - * @since 0.1.0 - */ -public interface GuildRoleAPI { - /** - * 获取服务器角色列表 - */ - API GUILD_ROLE_LIST = new API(API.Method.GET, "guild-role/list"); - /** - * 创建服务器角色 - */ - API GUILD_ROLE_CREATE = new API(API.Method.POST, "guild-role/create"); - /** - * 更新服务器角色 - */ - API GUILD_ROLE_UPDATE = new API(API.Method.POST, "guild-role/update"); - /** - * 删除服务器角色 - */ - API GUILD_ROLE_DELETE = new API(API.Method.POST, "guild-role/delete"); - /** - * 赋予用户角色 - */ - API GUILD_ROLE_GRANT = new API(API.Method.POST, "guild-role/grant"); - /** - * 删除用户角色 - */ - API GUILD_ROLE_REVOKE = new API(API.Method.POST, "guild-role/revoke"); -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/IntimacyAPI.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/IntimacyAPI.java deleted file mode 100644 index 4f8b94b..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/IntimacyAPI.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.api; - -/** - * 亲密度相关接口 - * - * @author Enaium - * @since 0.1.0 - */ -public interface IntimacyAPI { - /** - * 获取用户亲密度 - */ - API INTIMACY_INDEX = new API(API.Method.GET, "intimacy/index"); - /** - * 更新用户亲密度 - */ - API INTIMACY_UPDATE = new API(API.Method.POST, "intimacy/update"); -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/MessageAPI.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/MessageAPI.java deleted file mode 100644 index fbb9c63..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/MessageAPI.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.api; - -/** - * 频道消息相关接口 - * - * @author Enaium - * @since 0.1.0 - */ -public interface MessageAPI { - /** - * 获取频道聊天消息列表 - */ - API MESSAGE_LIST = new API(API.Method.GET, "message/list"); - /** - * 获取频道聊天消息详情 - */ - API MESSAGE_VIEW = new API(API.Method.GET, "message/view"); - /** - * 发送频道聊天消息 - */ - API MESSAGE_CREATE = new API(API.Method.POST, "message/create"); - /** - * 更新频道聊天消息 - */ - API MESSAGE_UPDATE = new API(API.Method.POST, "message/update"); - /** - * 删除频道聊天消息 - */ - API MESSAGE_DELETE = new API(API.Method.POST, "message/delete"); - /** - * 获取频道消息某回应的用户列表 - */ - API MESSAGE_REACTION_LIST = new API(API.Method.GET, "message/reaction-list"); - /** - * 给某个消息添加回应 - */ - API MESSAGE_ADD_REACTION = new API(API.Method.POST, "message/add-reaction"); - /** - * 删除消息的某个回应 - */ - API MESSAGE_DELETE_REACTION = new API(API.Method.POST, "message/delete-reaction"); - -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/configuration/KookConfiguration.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/configuration/KookConfiguration.java deleted file mode 100644 index 793d494..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/configuration/KookConfiguration.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.enaium.kook.spring.boot.starter.configuration; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -/** - * @author Enaium - */ -@Component -@ConfigurationProperties(value = "kook") -public class KookConfiguration { - /** - * 机器人的Token - */ - private String token; - - public void setToken(String token) { - this.token = token; - } - - public String getToken() { - return token; - } -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/connect/WebSocketClient.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/connect/WebSocketClient.java deleted file mode 100644 index 481a1d3..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/connect/WebSocketClient.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.connect; - -import cn.enaium.kook.spring.boot.starter.api.GatewayAPI; -import cn.enaium.kook.spring.boot.starter.configuration.KookConfiguration; -import cn.enaium.kook.spring.boot.starter.event.EventManager; -import cn.enaium.kook.spring.boot.starter.model.result.GatewayResult; -import cn.enaium.kook.spring.boot.starter.model.sign.Sign; -import cn.enaium.kook.spring.boot.starter.model.sign.data.EventData; -import cn.enaium.kook.spring.boot.starter.model.sign.data.ReconnectData; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.SystemMessageExtra; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.TextMessageExtra; -import cn.enaium.kook.spring.boot.starter.util.HttpUtil; -import cn.enaium.kook.spring.boot.starter.util.JsonUtil; -import cn.enaium.kook.spring.boot.starter.util.TimeUtil; -import com.fasterxml.jackson.core.type.TypeReference; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Component; -import org.springframework.web.socket.*; -import org.springframework.web.socket.client.WebSocketConnectionManager; -import org.springframework.web.socket.client.standard.StandardWebSocketClient; -import org.springframework.web.socket.handler.BinaryWebSocketHandler; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.util.HashMap; -import java.util.Map; -import java.util.Random; -import java.util.concurrent.TimeUnit; -import java.util.zip.Inflater; - -/** - * WebSocket客户端 - * - * @author Enaium - * @since 0.1.0 - */ -@Component -@Scope("prototype") -public class WebSocketClient { - private final Logger logger = LogManager.getLogger(WebSocketClient.class); - - public WebSocketConnectionManager connectionManager; - - public final KookConfiguration kookConfiguration; - - public final HttpUtil httpUtil; - - public final EventManager eventManager; - - - public WebSocketClient(KookConfiguration kookConfiguration, HttpUtil httpUtil, EventManager eventManager) { - this.kookConfiguration = kookConfiguration; - this.httpUtil = httpUtil; - this.eventManager = eventManager; - } - - public int sn = 0; - - public void start() { - - String url = httpUtil.send(GatewayAPI.GATEWAY_INDEX, GatewayResult.class).data.url; - - - StandardWebSocketClient webSocketClient = new StandardWebSocketClient(); - connectionManager = new WebSocketConnectionManager(webSocketClient, new BinaryWebSocketHandler() { - @Override - public void afterConnectionEstablished(WebSocketSession session) throws Exception { - logger.info("连接已经建立"); - ping(session); - } - - @Override - public void handleBinaryMessage(WebSocketSession session, BinaryMessage message) throws Exception { - String json = new String(decompress(message.getPayload().array()), StandardCharsets.UTF_8); - Sign sign = JsonUtil.readValue(json, Sign.class); - if (sign.s == 0) { - Sign eventDataSign = JsonUtil.readSign(json, EventData.class); - if (eventDataSign.d.type == 255) { - SystemMessageExtra extra = JsonUtil.mapper().readValue(json, new TypeReference>>>() { - }).d.extra; - String type = extra.type; - Class event = eventManager.listener.get(type); - eventManager.publish(JsonUtil.readData(JsonUtil.writeValueAsString(sign.d), event), event); - } else { - TextMessageExtra extra = JsonUtil.mapper().readValue(json, new TypeReference>>() { - }).d.extra; - String type = String.valueOf(extra.type); - //TODO 此功能目前治标不治本, 但是可以解决问题 - if ("0".equals(type)) { - type = String.valueOf(eventDataSign.d.type); - } - Class event = eventManager.listener.get(type); - eventManager.publish(JsonUtil.readData(JsonUtil.writeValueAsString(sign.d), event), event); - } - } else if (sign.s == 5) {//服务端通知客户端, 代表该连接已失效, 请重新连接。客户端收到后应该主动断开当前连接。 - Sign reconnectDataSign = JsonUtil.readSign(json, ReconnectData.class); - logger.info("err:{}", reconnectDataSign.d.err); - switch (reconnectDataSign.d.code) { - case 40106: - logger.info("resume 失败, 缺少参数"); - break; - case 40107: - logger.info("当前 session 已过期 (resume 失败, PING 的 sn 无效)"); - break; - case 40108: - logger.info("无效的 sn , 或 sn 已经不存在 (resume 失败, PING 的 sn 无效)"); - break; - } - connectionManager.stop(); - } - sn = sign.sn; - } - - final TimeUtil pong = new TimeUtil(); - - @Override - public void handlePongMessage(WebSocketSession session, PongMessage message) throws Exception { - - sn = JsonUtil.readValue(new String(message.getPayload().array(), StandardCharsets.UTF_8), Sign.class).sn; - TimeUtil.time(TimeUnit.SECONDS, 25 + new Random().nextInt(5), () -> ping(session)); - TimeUtil.time(TimeUnit.SECONDS, 1, () -> { - if (pong.delay(10000L)) { - logger.error("10秒内没收到Pong,连接超时"); - } - }); - } - - public void ping(WebSocketSession session) { - try { - session.sendMessage(new PingMessage(ByteBuffer.wrap(JsonUtil.writeValueAsString(new HashMap() {{ - put("s", 2); - put("sn", sn); - }}).getBytes(StandardCharsets.UTF_8)))); - } catch (IOException e) { - throw new RuntimeException(e); - } - pong.reset(); - } - - @Override - public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception { - logger.info("连接已经关闭"); - } - - @Override - public void handleTransportError(WebSocketSession session, Throwable exception) throws Exception { - logger.error(exception); - } - }, url); - connectionManager.start(); - } - - private byte[] decompress(byte[] data) { - byte[] output; - - Inflater decompresses = new Inflater(); - decompresses.reset(); - decompresses.setInput(data); - - ByteArrayOutputStream o = new ByteArrayOutputStream(data.length); - try { - byte[] buf = new byte[1024]; - while (!decompresses.finished()) { - int i = decompresses.inflate(buf); - o.write(buf, 0, i); - } - output = o.toByteArray(); - } catch (Exception e) { - output = data; - e.printStackTrace(); - } finally { - try { - o.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - decompresses.end(); - return output; - } -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/event/EventManager.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/event/EventManager.java deleted file mode 100644 index 8267f59..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/event/EventManager.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.event; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Event; -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.annotation.event.Register; -import org.springframework.context.ApplicationContext; -import org.springframework.stereotype.Component; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.CopyOnWriteArrayList; - -/** - * @author Enaium - * @since 0.1.0 - */ -@Component -public class EventManager { - public final Map> listener = new HashMap<>(); - - /** - * 键为事件类型 值为目标 - */ - public final Map, CopyOnWriteArrayList> event = new HashMap<>(); - - public EventManager(ApplicationContext applicationContext) { - //添加所有事件 - for (Object value : applicationContext.getBeansWithAnnotation(Listener.class).values()) { - Class klass = value.getClass(); - try { - listener.put(String.valueOf(klass.getField("TYPE").get(null)), klass); - } catch (IllegalAccessException | NoSuchFieldException e) { - throw new RuntimeException(e); - } - } - - //注册所有事件 - for (Object value : applicationContext.getBeansWithAnnotation(Register.class).values()) { - register(value); - } - } - - public void register(Object o) { - Class type = o.getClass(); - - for (Method method : type.getDeclaredMethods()) { - if (method.getParameterTypes().length == 1 && method.isAnnotationPresent(Event.class)) { - method.setAccessible(true); - Class event = method.getAnnotation(Event.class).value(); - - Target target = new Target(o, method, method.getAnnotation(Event.class).priority()); - - if (this.event.containsKey(event)) { - if (!this.event.get(event).contains(target)) { - this.event.get(event).add(target); - } - } else { - this.event.put(event, new CopyOnWriteArrayList<>(Collections.singletonList(target))); - } - } - } - event.values().forEach(it -> it.sort((Comparator.comparingInt(Target::getPriority)))); - } - - /** - * 发布事件 - * @param o 注册类的实例化 - * @param klass 监听器 - */ - public void publish(Object o, Class klass) { - CopyOnWriteArrayList targets = event.get(klass); - - if (targets == null) { - return; - } - - targets.forEach(event -> { - try { - event.getMethod().invoke(event.getInstance(), o); - } catch (IllegalAccessException | InvocationTargetException e) { - e.printStackTrace(); - } - }); - } -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/event/Target.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/event/Target.java deleted file mode 100644 index 5d4cb33..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/event/Target.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.event; - -import java.lang.reflect.Method; - -/** - * @author Enaium - */ -public class Target { - private final Object instance; - private final Method method; - private final int priority; - - public Target(Object instance, Method method, int priority) { - this.instance = instance; - this.method = method; - this.priority = priority; - } - - public Object getInstance() { - return instance; - } - - public Method getMethod() { - return method; - } - - public int getPriority() { - return priority; - } -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/constant/ChannelType.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/constant/ChannelType.java deleted file mode 100644 index e8db648..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/constant/ChannelType.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.constant; - -/** - * 消息通道类型, GROUP 为组播消息, PERSON 为单播消息, BROADCAST 为广播消息 - * - * @author Enaium - * @since 0.2.0 - */ -public interface ChannelType { - String GROUP = "GROUP"; - String PERSON = "PERSON"; - String BROADCAST = "BROADCAST"; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/constant/MessageType.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/constant/MessageType.java deleted file mode 100644 index 552cf2e..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/constant/MessageType.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.constant; - -/** - * 1:文字消息, 2:图片消息,3:视频消息,4:文件消息, 8:音频消息,9:KMarkdown,10:card 消息,12:动作消息 255:系统消息, 其它的暂未开放 - * - * @author Enaium - * @since 0.2.0 - */ -public interface MessageType { - int TEXT = 1; - int IMAGE = 2; - int VIDEO = 3; - int FILE = 4; - int AUDIO = 8; - int KMARKDOWN = 9; - int CARD = 10; - int SYSTEM = 255; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/object/AttachmentsObject.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/object/AttachmentsObject.java deleted file mode 100644 index b4cc490..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/object/AttachmentsObject.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.object; - -/** - * 附加的多媒体数据 - * - * @author Enaium - * @since 0.1.0 - */ -public class AttachmentsObject { - /** - * 多媒体类型 - */ - public String type; - /** - * 多媒体地址 - */ - public String url; - /** - * 多媒体名 - */ - public String name; - /** - * 大小单位(B) - */ - public int size; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/object/ChannelObject.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/object/ChannelObject.java deleted file mode 100644 index 47ed280..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/object/ChannelObject.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.object; - -/** - * 频道 - * - * @author Enaium - * @since 0.1.0 - */ -public class ChannelObject { - /** - * 频道id - */ - public String id; - /** - * 频道名称 - */ - public String name; - /** - * 创建者id - */ - public String user_id; - /** - * 服务器id - */ - public String guild_id; - /** - * 频道简介 - */ - public String topic; - /** - * 是否为分组,事件中为int格式 - */ - public boolean is_category; - /** - * 上级分组的id - */ - public String parent_id; - /** - * 排序level - */ - public int level; - /** - * 慢速模式下限制发言的最短时间间隔,单位为秒(s) - */ - public int slow_mode; - /** - * 频道类型:`1`文字频道,`2`语音频道 - */ - public int type; - /** - * 针对角色在该频道的权限覆写规则组成的列表 - */ - public Object[] permission_overwrites; - /** - * 针对用户在该频道的权限覆写规则组成的列表 - */ - public Object[] permission_users; - /** - * 权限设置是否与分组同步,`1`or`0` - */ - public int permission_sync; - /** - * 是否有密码 - */ - public boolean has_password; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/object/GuildObject.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/object/GuildObject.java deleted file mode 100644 index d0abd0a..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/object/GuildObject.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.object; - -/** - * 服务器 - * - * @author Enaium - * @since 0.1.0 - */ -public class GuildObject { - /** - * 服务器id - */ - public String id; - /** - * 服务器名称 - */ - public String name; - /** - * 服务器主题 - */ - public String topic; - /** - * 服务器主的id - */ - public String master_id; - /** - * 服务器icon的地址 - */ - public String icon; - /** - * 通知类型,`0`代表默认使用服务器通知设置,`1`代表接收所有通知,`2`代表仅@被提及,`3`代表不接收通知 - */ - public int notify_type; - /** - * 服务器默认使用语音区域 - */ - public String region; - /** - * 是否为公开服务器 - */ - public boolean enable_open; - /** - * 公开服务器id - */ - public String open_id; - /** - * 默认频道id - */ - public String default_channel_id; - /** - * 欢迎频道id - */ - public String welcome_channel_id; - /** - * 角色列表 - */ - public Object[] roles; - /** - * 频道列表 - */ - public Object[] channels; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/object/QuoteObject.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/object/QuoteObject.java deleted file mode 100644 index b756caf..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/object/QuoteObject.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.object; - -/** - * 引用消息 - * - * @author Enaium - * @since 0.1.0 - */ -public class QuoteObject { - /** - * 引用消息id - */ - public String id; - /** - * 引用消息类型 - */ - public int type; - /** - * 引用消息内容 - */ - public String content; - /** - * 引用消息创建时间(毫秒) - */ - public int create_at; - /** - * 作者的用户信息 - */ - public UserObject author; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/object/RoleObject.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/object/RoleObject.java deleted file mode 100644 index 3c32853..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/object/RoleObject.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.object; - -/** - * 角色 - * - * @author Enaium - * @since 0.1.0 - */ -public class RoleObject { - /** - * 角色id - */ - public int role_id; - /** - * 角色名称 - */ - public String name; - /** - * 颜色色值 - */ - public int color; - /** - * 顺序位置 - */ - public int position; - /** - * 是否为角色设定(与普通成员分开显示) - */ - public int hoist; - /** - * 是否允许任何人@提及此角色 - */ - public int mentionable; - /** - * 权限码 - */ - public int permissions; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/object/UserObject.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/object/UserObject.java deleted file mode 100644 index fc38a24..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/object/UserObject.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.object; - -/** - * 用户 - * - * @author Enaium - * @since 0.1.0 - */ -public class UserObject { - /** - * 用户的id - */ - public String id; - /** - * 用户的名称 - */ - public String username; - /** - * 用户在当前服务器的昵称 - */ - public String nickname; - /** - * 用户名的认证数字,用户名正常为:user_name#identify_num - */ - public String identify_num; - /** - * 当前是否在线 - */ - public boolean online; - /** - * 是否为机器人 - */ - public boolean bot; - /** - * 用户的状态,0和1代表正常,10代表被封禁 - */ - public int status; - /** - * 用户的头像的url地址 - */ - public String avatar; - /** - * vip用户的头像的url地址,可能为gif动图 - */ - public String vip_avatar; - /** - * 是否手机号已验证 - */ - public boolean mobile_verified; - /** - * 用户在当前服务器中的角色id组成的列表 - */ - public Object[] roles; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/result/Result.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/result/Result.java deleted file mode 100644 index caaf218..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/result/Result.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.result; - -import com.fasterxml.jackson.databind.ObjectMapper; - -/** - * @author Enaium - * @since 0.1.0 - */ -public class Result { - public int code; - public String message; - public T data; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/EventData.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/EventData.java deleted file mode 100644 index 136252d..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/EventData.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data; - -public class EventData { - /** - * 消息通道类型, GROUP 为组播消息, PERSON 为单播消息, BROADCAST 为广播消息 - */ - public String channel_type; - - /** - * 1:文字消息, 2:图片消息,3:视频消息,4:文件消息, 8:音频消息,9:KMarkdown,10:card 消息,255:系统消息, 其它的暂未开放 - */ - public int type; - - /** - * 发送目的, 频道消息类时, 代表的是频道 channel_id,如果 channel_type 为 GROUP 组播且 type 为 255 系统消息时,则代表服务器 guild_id - */ - public String target_id; - - /** - * 发送者 id, 1 代表系统 - */ - public String author_id; - - /** - * 消息内容, 文件,图片,视频时,content 为 url - */ - public String content; - - /** - * 消息的 id - */ - public String msg_id; - - /** - * 消息发送时间的毫秒时间戳 - */ - public long msg_timestamp; - - /** - * 随机串,与用户消息发送 api 中传的 nonce 保持一致 - */ - public String nonce; - - /** - * 不同的消息类型,结构不一致 - */ - public T extra; -} \ No newline at end of file diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/SystemMessageExtra.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/SystemMessageExtra.java deleted file mode 100644 index 8392700..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/SystemMessageExtra.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra; - -/** - * @author Enaium - * @since 0.1.0 - */ -public class SystemMessageExtra { - /** - * 标识该事件的类型 - */ - public String type; - - /** - * 该事件关联的具体数据, 详见各系统消息事件示例 - */ - public T body; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/TextMessageExtra.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/TextMessageExtra.java deleted file mode 100644 index f92f7c3..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/TextMessageExtra.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra; - -import cn.enaium.kook.spring.boot.starter.model.object.UserObject; - -/** - * @author Enaium - * @since 0.1.0 - */ -public class TextMessageExtra { - /** - * 1:文字消息, 2:图片消息,3:视频消息,4:文件消息, 8:音频消息,9:KMarkdown,10:card 消息,12:动作消息 255:系统消息, 其它的暂未开放 - */ - public int type; - - public String code; - - /** - * 服务器 id - */ - public String guild_id; - - /** - * 频道名 - */ - public String channel_name; - - /** - * 提及到的用户 id 的列表 - */ - public Object[] mention; - - /** - * 是否 mention 所有用户 - */ - public boolean mention_all; - - /** - * mention 用户角色的数组 - */ - public Object[] mention_roles; - - /** - * 是否 mention 在线用户 - */ - public boolean mention_here; - - /** - * 用户信息 - */ - public UserObject author; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/channel/AddedChannel.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/channel/AddedChannel.java deleted file mode 100644 index 2812371..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/channel/AddedChannel.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.channel; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.object.ChannelObject; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.SystemMessageExtra; - -/** - * 新增频道 - * - * @author Enaium - * @since 0.1.0 - */ -@Listener -public class AddedChannel extends SystemMessageExtra { - - public static final String TYPE = "added_channel"; - -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/channel/AddedReactionChannel.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/channel/AddedReactionChannel.java deleted file mode 100644 index ffe429a..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/channel/AddedReactionChannel.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.channel; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.SystemMessageExtra; - -import java.util.Map; - -/** - * 频道内用户添加 reaction - * - * @author Enaium - */ -@Listener -public class AddedReactionChannel extends SystemMessageExtra> { - - public static final String TYPE = "added_reaction"; - - /** - * 用户点击的消息 id - */ - public String msg_id; - /** - * 点击的用户 - */ - public String user_id; - /** - * 频道 id - */ - public String channel_id; - /** - * 消息对象, 包含 id 表情 id, name 表情名称 - */ - public Map emoji; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/channel/DeletedChannel.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/channel/DeletedChannel.java deleted file mode 100644 index b6fcd07..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/channel/DeletedChannel.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.channel; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.SystemMessageExtra; - -import java.util.Map; - -/** - * 删除频道 - * - * @author Enaium - * @since 0.1.0 - */ -@Listener -public class DeletedChannel extends SystemMessageExtra> { - - public static final String TYPE = "deleted_channel"; - - /** - * 被删掉的频道 id - */ - public String id; - /** - * 删除时间(毫秒) - */ - public int deleted_at; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/channel/DeletedMessageChannel.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/channel/DeletedMessageChannel.java deleted file mode 100644 index b504890..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/channel/DeletedMessageChannel.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.channel; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.SystemMessageExtra; - -import java.util.Map; - -/** - * 频道消息被删除 - * - * @author Enaium - * @since 0.1.0 - */ -@Listener -public class DeletedMessageChannel extends SystemMessageExtra> { - - public static final String TYPE = "deleted_message"; - - /** - * 被更新的消息的 id - */ - public String msg_id; - /** - * 频道 id - */ - public String channel_id; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/channel/DeletedReactionChannel.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/channel/DeletedReactionChannel.java deleted file mode 100644 index 4858b3f..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/channel/DeletedReactionChannel.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.channel; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.SystemMessageExtra; - -import java.util.Map; - -/** - * 频道内用户取消 reaction - * - * @author Enaium - * @since 0.1.0 - */ -@Listener -public class DeletedReactionChannel extends SystemMessageExtra> { - - public static final String TYPE = "deleted_reaction"; - - /** - * 用户点击的消息 id - */ - public String msg_id; - /** - * 点击的用户 - */ - public String user_id; - /** - * 频道 id - */ - public String channel_id; - /** - * 消息对象, 包含 id 表情 id, name 表情名称 - */ - public Map emoji; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/channel/PinnedMessageChannel.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/channel/PinnedMessageChannel.java deleted file mode 100644 index 97103cb..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/channel/PinnedMessageChannel.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.channel; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.SystemMessageExtra; - -import java.util.Map; - -/** - * 新的频道置顶消息 - * - * @author Enaium - * @since 0.1.0 - */ -@Listener -public class PinnedMessageChannel extends SystemMessageExtra> { - - public static final String TYPE = "pinned_message"; - - /** - * 频道 id - */ - public String channel_id; - /** - * 操作人 id - */ - public String operator_id; - /** - * 被置顶的消息 id - */ - public String msg_id; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/channel/UnpinnedMessageChannel.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/channel/UnpinnedMessageChannel.java deleted file mode 100644 index 35953e8..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/channel/UnpinnedMessageChannel.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.channel; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.SystemMessageExtra; - -import java.util.Map; - -/** - * 取消频道置顶消息 - * - * @author Enaium - * @since 0.1.0 - */ -@Listener -public class UnpinnedMessageChannel extends SystemMessageExtra> { - - public static final String TYPE = "unpinned_message"; - - /** - * 频道 id - */ - public String channel_id; - /** - * 操作人 id - */ - public String operator_id; - /** - * 被置顶的消息 id - */ - public String msg_id; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/channel/UpdateMessageChannel.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/channel/UpdateMessageChannel.java deleted file mode 100644 index 6892813..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/channel/UpdateMessageChannel.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.channel; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.SystemMessageExtra; - -import java.util.Map; - -/** - * 频道消息更新 - * - * @author Enaium - * @since 0.1.0 - */ -@Listener -public class UpdateMessageChannel extends SystemMessageExtra> { - - public static final String TYPE = "updated_message"; - - /** - * 被更新的消息的 id - */ - public String msg_id; - /** - * 更新后的文本 - */ - public String content; - /** - * 频道 id - */ - public String channel_id; - /** - * 提及的用户 id 组成的列表 - */ - public Object[] mention; - /** - * 是否提及全体成员 - */ - public boolean mention_all; - /** - * 是否提及在线成员 - */ - public boolean mention_here; - /** - * 提及的角色 id 组成的列表 - */ - public Object[] mention_roles; - /** - * 更新时间戳(毫秒) - */ - public int updated_at; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/channel/UpdatedChannel.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/channel/UpdatedChannel.java deleted file mode 100644 index f0c3309..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/channel/UpdatedChannel.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.channel; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.object.ChannelObject; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.SystemMessageExtra; - -/** - * 修改频道信息 - * - * @author Enaium - * @since 0.1.0 - */ -@Listener -public class UpdatedChannel extends SystemMessageExtra { - - public static final String TYPE = "updated_channel"; - -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/member/GuildOfflineMember.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/member/GuildOfflineMember.java deleted file mode 100644 index a5f37bd..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/member/GuildOfflineMember.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.member; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.SystemMessageExtra; - -import java.util.Map; - -/** - * 服务器成员下线 - * - * @author Enaium - * @since 0.1.0 - */ -@Listener -public class GuildOfflineMember extends SystemMessageExtra> { - public static final String TYPE = "guild_member_offline"; - - /** - * 用户id - */ - public String user_id; - /** - * 事件发生的时间 - */ - public int event_time; - /** - * 服务器 id 组成的数组, 代表与该用户所在的共同的服务器 - */ - public Object[] guilds; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/member/GuildOnlineMember.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/member/GuildOnlineMember.java deleted file mode 100644 index 4301b13..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/member/GuildOnlineMember.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.member; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.SystemMessageExtra; - -import java.util.Map; - -/** - * 服务器成员上线 - * - * @author Enaium - * @since 0.1.0 - */ -@Listener -public class GuildOnlineMember extends SystemMessageExtra> { - public static final String TYPE = "guild_member_online"; - - /** - * 用户id - */ - public String user_id; - /** - * 事件发生的时间 - */ - public int event_time; - /** - * 服务器 id 组成的数组, 代表与该用户所在的共同的服务器 - */ - public Object[] guilds; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/member/JoinedGuildMember.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/member/JoinedGuildMember.java deleted file mode 100644 index a4d99b8..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/member/JoinedGuildMember.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.member; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.SystemMessageExtra; - -import java.util.Map; - -/** - * 新成员加入服务器 - * - * @author Enaium - * @since 0.1.0 - */ -@Listener -public class JoinedGuildMember extends SystemMessageExtra> { - public static final String TYPE = "joined_guild"; - - /** - * 用户 id - */ - public String user_id; - /** - * 加入服务器的时间 - */ - public int joined_at; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/member/UpdatedGuildMember.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/member/UpdatedGuildMember.java deleted file mode 100644 index b610f17..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/member/UpdatedGuildMember.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.member; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.SystemMessageExtra; - -import java.util.Map; - -/** - * 服务器成员信息更新 - * - * @author Enaium - * @since 0.1.0 - */ -@Listener -public class UpdatedGuildMember extends SystemMessageExtra> { - - public static final String TYPE = "updated_guild_member"; - - /** - * 用户 id - */ - public String user_id; - /** - * 昵称 - */ - public String nickname; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/message/CardMessage.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/message/CardMessage.java deleted file mode 100644 index d497256..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/message/CardMessage.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.message; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.TextMessageExtra; - -import java.util.Map; - -/** - * Card 消息 - * - * @author Enaium - * @since 0.1.0 - */ -@Listener -public class CardMessage extends TextMessageExtra { - public static final String TYPE = "10"; - - public Map kmarkdown; - - public Object[] nav_channels; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/message/FileMessage.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/message/FileMessage.java deleted file mode 100644 index 89fb4dd..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/message/FileMessage.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.message; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.TextMessageExtra; - -import java.util.Map; - -/** - * 文件消息 - * - * @author Enaium - * @since 0.1.0 - */ -@Listener -public class FileMessage extends TextMessageExtra { - - public static final String TYPE = "4"; - - /** - * 附件 - */ - public Map attachments; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/message/ImageAnimationMessage.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/message/ImageAnimationMessage.java deleted file mode 100644 index ade9dbf..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/message/ImageAnimationMessage.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.message; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.TextMessageExtra; - -import java.util.Map; - -/** - * 动作消息,可能并非正式命名 - * 详细报文可见 kook/api-docs - * @author CNLuminous - * @since 0.1.4 - */ -@Listener -public class ImageAnimationMessage extends TextMessageExtra { - public static final String TYPE = "12"; - - public Map kmarkdown; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/message/ImageMessage.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/message/ImageMessage.java deleted file mode 100644 index 98b1a2a..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/message/ImageMessage.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.message; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.TextMessageExtra; - -import java.util.Map; - -/** - * 图片消息 - * - * @author Enaium - * @since 0.1.0 - */ -@Listener -public class ImageMessage extends TextMessageExtra { - - public static final String TYPE = "2"; - - /** - * 附件 - */ - public Map attachments; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/message/KMarkdownMessage.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/message/KMarkdownMessage.java deleted file mode 100644 index d8f1672..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/message/KMarkdownMessage.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.message; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.TextMessageExtra; - -import java.util.Map; - -/** - * KMarkdown 消息 - * - * @author Enaium - * @since 0.1.0 - */ -@Listener -public class KMarkdownMessage extends TextMessageExtra { - - public static final String TYPE = "9"; - - public Map kmarkdown; - - public Object[] nav_channels; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/message/TextMessage.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/message/TextMessage.java deleted file mode 100644 index 25d7bdc..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/message/TextMessage.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.message; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.TextMessageExtra; - -/** - * 文字消息 - * - * @author Enaium - * @since 0.1.0 - */ -@Listener -public class TextMessage extends TextMessageExtra { - public static final String TYPE = "1"; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/message/VideoMessage.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/message/VideoMessage.java deleted file mode 100644 index 5529334..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/message/VideoMessage.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.message; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.TextMessageExtra; - -import java.util.Map; - -/** - * 视频消息 - * - * @author Enaium - * @since 0.1.0 - */ -@Listener -public class VideoMessage extends TextMessageExtra { - - public static final String TYPE = "3"; - - /** - * 附件 - */ - public Map attachments; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/pm/AddedReactionPrivateMessage.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/pm/AddedReactionPrivateMessage.java deleted file mode 100644 index fa7b0dc..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/pm/AddedReactionPrivateMessage.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.pm; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.SystemMessageExtra; - -import java.util.Map; - -/** - * 私聊内用户添加 reaction - * - * @author Enaium - * @since 0.1.0 - */ -@Listener -public class AddedReactionPrivateMessage extends SystemMessageExtra> { - public static final String TYPE = "private_added_reaction"; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/pm/DeletedPrivateMessage.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/pm/DeletedPrivateMessage.java deleted file mode 100644 index 547bb38..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/pm/DeletedPrivateMessage.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.pm; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.SystemMessageExtra; - -import java.util.Map; - -/** - * 私聊消息被删除 - * - * @author Enaium - * @since 0.1.0 - */ -@Listener -public class DeletedPrivateMessage extends SystemMessageExtra> { - public static final String TYPE = "deleted_private_message"; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/pm/DeletedReactionPrivateMessage.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/pm/DeletedReactionPrivateMessage.java deleted file mode 100644 index 7635d84..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/pm/DeletedReactionPrivateMessage.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.pm; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.SystemMessageExtra; - -import java.util.Map; - -/** - * 私聊内用户取消 reaction - * - * @author Enaium - * @since 0.1.0 - */ -@Listener -public class DeletedReactionPrivateMessage extends SystemMessageExtra> { - public static final String TYPE = "private_deleted_reaction"; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/pm/UpdatedPrivateMessage.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/pm/UpdatedPrivateMessage.java deleted file mode 100644 index 14c7033..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/pm/UpdatedPrivateMessage.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.pm; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.SystemMessageExtra; - -import java.util.Map; - -/** - * 私聊消息更新 - * - * @author Enaium - * @since 0.1.0 - */ -@Listener -public class UpdatedPrivateMessage extends SystemMessageExtra> { - public static final String TYPE = "updated_private_message"; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/role/AddedRole.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/role/AddedRole.java deleted file mode 100644 index d5b8912..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/role/AddedRole.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.role; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.object.RoleObject; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.SystemMessageExtra; - -/** - * 服务器角色增加 - * - * @author Enaium - * @since 0.1.0 - */ -@Listener -public class AddedRole extends SystemMessageExtra { - public static final String TYPE = "added_role"; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/role/DeletedRole.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/role/DeletedRole.java deleted file mode 100644 index 8fc06e1..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/role/DeletedRole.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.role; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.object.RoleObject; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.SystemMessageExtra; - -/** - * 服务器角色删除 - * - * @author Enaium - * @since 0.1.0 - */ -@Listener -public class DeletedRole extends SystemMessageExtra { - public static final String TYPE = "deleted_role"; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/role/UpdatedRole.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/role/UpdatedRole.java deleted file mode 100644 index 151bc73..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/role/UpdatedRole.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.role; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.object.RoleObject; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.SystemMessageExtra; - -/** - * 服务器角色更新 - * - * @author Enaium - * @since 0.1.0 - */ -@Listener -public class UpdatedRole extends SystemMessageExtra { - public static final String TYPE = "updated_role"; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/server/AddedBlockListServer.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/server/AddedBlockListServer.java deleted file mode 100644 index 3f84d36..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/server/AddedBlockListServer.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.server; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.SystemMessageExtra; - -import java.util.Map; - -/** - * 服务器封禁用户 - * - * @author Enaium - * @since 0.1.0 - */ -@Listener -public class AddedBlockListServer extends SystemMessageExtra> { - - public static final String TYPE = "added_block_list"; - - /** - * 操作人 id - */ - public String operator_id; - /** - * 封禁理由 - */ - public String remark; - /** - * 被封禁成员 id 列表 - */ - public Object[] user_id; -} - diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/server/DeletedGuildServer.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/server/DeletedGuildServer.java deleted file mode 100644 index 3fd2b89..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/server/DeletedGuildServer.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.server; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.SystemMessageExtra; - -import java.util.Map; - -/** - * 服务器删除 - * - * @author Enaium - * @since 0.1.0 - */ -@Listener -public class DeletedGuildServer extends SystemMessageExtra> { - - public static final String TYPE = "deleted_guild"; - - /** - * 服务器 id - */ - public String id; - - /** - * 服务器名称 - */ - public String name; - - /** - * 服务器主 id - */ - public String user_id; - - /** - * 服务器 logo 图片地址 - */ - public String icon; - /** - * 通知类型 1接受所有通知 2仅接收被提及消息 3不接收通知 - */ - public int notify_type; - /** - * 服务器所在区域 - */ - public String region; - /** - * 是否为公开服务器, 1 or 0 - */ - public int enable_open; - /** - * 公开服务器 id - */ - public int open_id; - /** - * 默认文字频道 id - */ - public String default_channel_id; - /** - * 欢迎频道 id - */ - public String welcome_channel_id; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/server/UpdatedGuildServer.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/server/UpdatedGuildServer.java deleted file mode 100644 index 7346400..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/server/UpdatedGuildServer.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.server; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.SystemMessageExtra; - -import java.util.Map; - -/** - * 服务器信息更新 - * - * @author Enaium - * @since 0.1.0 - */ -@Listener -public class UpdatedGuildServer extends SystemMessageExtra> { - - public static final String TYPE = "updated_guild"; - - /** - * 服务器 id - */ - public String id; - - /** - * 服务器名称 - */ - public String name; - - /** - * 服务器主 id - */ - public String user_id; - - /** - * 服务器 logo 图片地址 - */ - public String icon; - /** - * 通知类型 1接受所有通知 2仅接收被提及消息 3不接收通知 - */ - public int notify_type; - /** - * 服务器所在区域 - */ - public String region; - /** - * 是否为公开服务器, 1 or 0 - */ - public int enable_open; - /** - * 公开服务器 id - */ - public int open_id; - /** - * 默认文字频道 id - */ - public String default_channel_id; - /** - * 欢迎频道 id - */ - public String welcome_channel_id; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/user/ExitedChannelUser.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/user/ExitedChannelUser.java deleted file mode 100644 index 3670009..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/user/ExitedChannelUser.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.user; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.SystemMessageExtra; - -import java.util.Map; - -/** - * 用户退出语音频道 - * - * @author Enaium - * @since 0.1.0 - */ -@Listener -public class ExitedChannelUser extends SystemMessageExtra> { - public static final String TYPE = "exited_channel"; - /** - * 用户 id - */ - public String user_id; - /** - * 加入的频道 id - */ - public String channel_id; - /** - * 退出时间 - */ - public int exited_at; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/user/JoinedChannelUser.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/user/JoinedChannelUser.java deleted file mode 100644 index 6289b88..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/user/JoinedChannelUser.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.user; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.SystemMessageExtra; - -import java.util.Map; - -/** - * 用户加入语音频道 - * - * @author Enaium - * @since 0.1.0 - */ -@Listener -public class JoinedChannelUser extends SystemMessageExtra> { - public static final String TYPE = "joined_channel"; - /** - * 用户 id - */ - public String user_id; - /** - * 加入的频道 id - */ - public String channel_id; - /** - * 加入时间 - */ - public int joined_at; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/user/MessageBtnClickUser.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/user/MessageBtnClickUser.java deleted file mode 100644 index 3649594..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/user/MessageBtnClickUser.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.user; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.object.UserObject; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.SystemMessageExtra; - -import java.util.Map; - -/** - * @author Enaium - */ -@Listener -public class MessageBtnClickUser extends SystemMessageExtra> { - public static final String TYPE = "message_btn_click"; - /** - * 用户点击的消息 id - */ - public String msg_id; - /** - * 点击的用户 - */ - public String user_id; - /** - * return-val 的值 - */ - public String value; - /** - * 消息发送的目标 id,频道消息为频道 - */ - public String target_id; - /** - * 用户信息,同 User Object - */ - public UserObject user_info; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/user/SelfExitedGuildUser.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/user/SelfExitedGuildUser.java deleted file mode 100644 index a7b5f50..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/user/SelfExitedGuildUser.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.user; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.SystemMessageExtra; - -import java.util.Map; - -/** - * 自己新加入服务器 - *

- * 当自己被邀请或主动加入新的服务器时, 产生该事件 - * - * @author Enaium - * @since 0.1.0 - */ -@Listener -public class SelfExitedGuildUser extends SystemMessageExtra> { - public static final String TYPE = "self_exited_guild"; - - /** - * 服务器 id - */ - public String guild_id; - -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/user/SelfJoinedGuildUser.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/user/SelfJoinedGuildUser.java deleted file mode 100644 index 16b55a8..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/user/SelfJoinedGuildUser.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.user; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.SystemMessageExtra; - -import java.util.Map; - -/** - * 自己新加入服务器 - *

- * 当自己被邀请或主动加入新的服务器时, 产生该事件 - * - * @author Enaium - * @since 0.1.0 - */ -@Listener -public class SelfJoinedGuildUser extends SystemMessageExtra> { - public static final String TYPE = "self_joined_guild"; - - /** - * 服务器 id - */ - public String guild_id; - -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/user/UpdatedUser.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/user/UpdatedUser.java deleted file mode 100644 index 4ec99c6..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/user/UpdatedUser.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.user; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.SystemMessageExtra; - -import java.util.Map; - -/** - * 用户信息更新 - *

- * 该事件与服务器无关, 遵循以下条件 - *

- * 1.仅当用户的 用户名 或 头像 变更时; - * - * 2仅通知与该用户存在关联的用户或 Bot: a. 存在聊天会话 b. 双方好友关系 - * - * @author Enaium - * @since 0.1.0 - */ -@Listener -public class UpdatedUser extends SystemMessageExtra> { - public static final String TYPE = "user_updated"; - /** - * 用户 id - */ - public String user_id; - /** - * 用户名 - */ - public String username; - /** - * 头像图片地址 - */ - public String avatar; -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/util/ASyncUtil.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/util/ASyncUtil.java deleted file mode 100644 index 122cf94..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/util/ASyncUtil.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.util; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -/** - * @author Enaium - * @since 0.1.0 - */ -public class ASyncUtil { - public static void execute(Runnable run) { - ExecutorService executorService = Executors.newSingleThreadExecutor(); - executorService.execute(run); - } -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/util/HttpUtil.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/util/HttpUtil.java deleted file mode 100644 index 6ad350a..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/util/HttpUtil.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.util; - -import cn.enaium.kook.spring.boot.starter.api.API; -import cn.enaium.kook.spring.boot.starter.configuration.KookConfiguration; -import cn.enaium.kook.spring.boot.starter.model.result.Result; -import com.fasterxml.jackson.databind.type.TypeFactory; -import kong.unirest.HttpRequestWithBody; -import kong.unirest.Unirest; -import org.springframework.stereotype.Component; - -import java.io.IOException; -import java.util.Map; - -/** - * @author Enaium - * @since 0.1.0 - */ -@Component -public class HttpUtil { - public static final String PREFIX = "https://www.kookapp.cn/api/v3/"; - - private final KookConfiguration kookConfiguration; - - public HttpUtil(KookConfiguration kookConfiguration) { - this.kookConfiguration = kookConfiguration; - } - - /** - * 创建请求 - * - * @param api api - * @return 请求体 - */ - public HttpRequestWithBody request(API api) { - API.Method method = api.getMethod(); - String path = api.getPath(); - Map body = api.getBody(); - - if (method.equals(API.Method.GET)) { - //当Method为Get时,需要将参数拼接在url上 - if (null != body && !body.isEmpty()) { - path += "?"; - StringBuilder sb = new StringBuilder(); - body.forEach((k, v) -> { - sb.append("&").append(k.toString()).append("=").append(v.toString()); - }); - path += sb.substring(1); - } - } - return Unirest.request(method.name(), PREFIX + path).header("Authorization", "Bot " + kookConfiguration.getToken()); - } - - /** - * 发送请求 - * - * @param api api - * @return 返回的字符串 - */ - public String send(API api) { - HttpRequestWithBody request = request(api); - if (api.getBody() != null) { - return request.body(api.getBody()).header("Content-Type", "application/json").asString().getBody(); - } - return request.asString().getBody(); - } - - /** - * 发送请求 - * - * @param api api - * @param klass 返回类型 - * @param 返回类型 - * @return 根据类型将返回值序列化 - */ - public Result send(API api, Class klass) { - try { - return JsonUtil.mapper().readValue(send(api), TypeFactory.defaultInstance().constructParametricType(Result.class, klass)); - } catch (IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/util/JsonUtil.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/util/JsonUtil.java deleted file mode 100644 index 5946f0a..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/util/JsonUtil.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.util; - -import cn.enaium.kook.spring.boot.starter.model.sign.Sign; -import cn.enaium.kook.spring.boot.starter.model.sign.data.EventData; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.type.TypeFactory; - -/** - * @author Enaium - */ -public class JsonUtil { - - public static T readValue(String string, Class klass) { - try { - return mapper().readValue(string, klass); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); - } - } - - public static Sign readSign(String string, Class klass) { - try { - return mapper().readValue(string, TypeFactory.defaultInstance().constructParametricType(Sign.class, klass)); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); - } - } - - public static EventData readData(String string, Class klass) { - try { - return mapper().readValue(string, TypeFactory.defaultInstance().constructParametricType(EventData.class, klass)); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); - } - } - - - public static String writeValueAsString(Object o) { - try { - return mapper().writeValueAsString(o); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); - } - } - - - public static ObjectMapper mapper() { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - return objectMapper; - } -} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/util/TimeUtil.java b/core/src/main/java/cn/enaium/kook/spring/boot/starter/util/TimeUtil.java deleted file mode 100644 index 5ca15c6..0000000 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/util/TimeUtil.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.util; - -import java.util.concurrent.TimeUnit; - -/** - * @author Enaium - * @since 0.1.0 - */ -public class TimeUtil { - - private long lastMS = -1L; - - public boolean delay(double nextDelay) { - return (double) (System.currentTimeMillis() - this.lastMS) >= nextDelay; - } - - public void reset() { - this.lastMS = System.currentTimeMillis(); - } - - public long getLastMS() { - return lastMS; - } - - public static void time(TimeUnit timeUnit, long timeout, Runnable runnable) { - ASyncUtil.execute(() -> { - try { - timeUnit.sleep(timeout); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - runnable.run(); - }); - } -} \ No newline at end of file diff --git a/core/src/main/resources/META-INF/spring.factories b/core/src/main/resources/META-INF/spring.factories deleted file mode 100644 index df7e511..0000000 --- a/core/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,2 +0,0 @@ -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ - cn.enaium.kook.spring.boot.starter.KookSpringBootStarter \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 41d9927..249e583 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8049c68..59bc51a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..a69d9cb --- /dev/null +++ b/gradlew @@ -0,0 +1,240 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..f127cfd --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,91 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/jitpack.yml b/jitpack.yml new file mode 100644 index 0000000..1e41e00 --- /dev/null +++ b/jitpack.yml @@ -0,0 +1,2 @@ +jdk: + - openjdk17 \ No newline at end of file diff --git a/kookstarter-sample/.gitignore b/kookstarter-sample/.gitignore new file mode 100644 index 0000000..6028782 --- /dev/null +++ b/kookstarter-sample/.gitignore @@ -0,0 +1,44 @@ +.gradle +build/ +!gradle/wrapper/gradle-wrapper.jar +!**/src/main/**/build/ +!**/src/test/**/build/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store + +src/main/resources/application.yaml \ No newline at end of file diff --git a/kookstarter-sample/README.md b/kookstarter-sample/README.md new file mode 100644 index 0000000..2a17b54 --- /dev/null +++ b/kookstarter-sample/README.md @@ -0,0 +1,14 @@ +# 例子 + +记得在`resources`下创建一个配置文件`application.properties`文件 + +```properties +kook.token=机器人的Token +``` + +或 + +```yaml +kook: + token: 机器人的Token +``` \ No newline at end of file diff --git a/kookstarter-sample/build.gradle.kts b/kookstarter-sample/build.gradle.kts new file mode 100644 index 0000000..f21ad79 --- /dev/null +++ b/kookstarter-sample/build.gradle.kts @@ -0,0 +1,11 @@ +plugins { + java + id("org.springframework.boot") version "3.0.5" + id("io.spring.dependency-management") version "1.1.0" +} + +dependencies { + implementation(project(":kookstarter")) + + implementation("org.springframework.boot:spring-boot-starter-webflux") +} \ No newline at end of file diff --git a/kookstarter-sample/src/main/java/cn/enaium/kookstarter/sample/SampleApplication.java b/kookstarter-sample/src/main/java/cn/enaium/kookstarter/sample/SampleApplication.java new file mode 100644 index 0000000..408af50 --- /dev/null +++ b/kookstarter-sample/src/main/java/cn/enaium/kookstarter/sample/SampleApplication.java @@ -0,0 +1,97 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.sample; + +import cn.enaium.kookstarter.client.http.DirectMessageService; +import cn.enaium.kookstarter.client.http.MessageService; +import cn.enaium.kookstarter.event.KMarkdownEvent; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.event.EventListener; +import reactor.core.publisher.Mono; + +import java.util.Map; + +import static cn.enaium.kookstarter.KookStarter.LOGGER; + +/** + * @author Enaium + * @since 0.3.0 + */ +@SpringBootApplication +public class SampleApplication { + + private final MessageService messageService; + private final DirectMessageService directMessageService; + + public SampleApplication(MessageService messageService, DirectMessageService directMessageService) { + this.messageService = messageService; + this.directMessageService = directMessageService; + } + + public static void main(String[] args) { + SpringApplication.run(SampleApplication.class, args); + } + + + @EventListener + public void event(KMarkdownEvent event) throws JsonProcessingException { + final var jsonNode = new ObjectMapper().readValue(event.getMetadata().toString(), JsonNode.class); + final var data = jsonNode.get("d"); + final var type = data.get("channel_type").textValue(); + final var content = data.get("extra").get("kmarkdown").get("raw_content").textValue(); + final var bot = data.get("extra").get("author").get("bot").booleanValue(); + + if (bot) {//对方是否为机器人 + return; + } + + LOGGER.info("对方说了{}", content); + if (type.equals("PERSON")) { + directMessageService.postDirectMessageCreate( + Map.of( + "type", 9, + "target_id", data.get("author_id"), + "content", "**Hello**" + ) + ).doOnSuccess(result -> { + LOGGER.info("请求成功:{}", result); + }).doOnError(throwable -> { + LOGGER.error("请求错误"); + throwable.printStackTrace(); + }).subscribe(); + + + } else if (type.equals("GROUP")) { + messageService.postMessageCreate( + Map.of( + "type", 9, + "target_id", data.get("target_id"), + "content", "**Hello**" + ) + ).doOnSuccess(result -> { + LOGGER.info("请求成功:{}", result); + }).doOnError(throwable -> { + LOGGER.error("请求错误"); + throwable.printStackTrace(); + }).block(); + } + } +} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/ReconnectData.java b/kookstarter-sample/src/main/java/cn/enaium/kookstarter/sample/SampleComponent.java similarity index 77% rename from core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/ReconnectData.java rename to kookstarter-sample/src/main/java/cn/enaium/kookstarter/sample/SampleComponent.java index a13d169..e8635d0 100644 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/ReconnectData.java +++ b/kookstarter-sample/src/main/java/cn/enaium/kookstarter/sample/SampleComponent.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Enaium + * Copyright 2023 Enaium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,12 +14,14 @@ * limitations under the License. */ -package cn.enaium.kook.spring.boot.starter.model.sign.data; +package cn.enaium.kookstarter.sample; + +import org.springframework.stereotype.Component; /** * @author Enaium + * @since 0.3.0 */ -public class ReconnectData { - public int code; - public String err; +@Component +public class SampleComponent { } diff --git a/kookstarter/.gitignore b/kookstarter/.gitignore new file mode 100644 index 0000000..b63da45 --- /dev/null +++ b/kookstarter/.gitignore @@ -0,0 +1,42 @@ +.gradle +build/ +!gradle/wrapper/gradle-wrapper.jar +!**/src/main/**/build/ +!**/src/test/**/build/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/kookstarter/build.gradle.kts b/kookstarter/build.gradle.kts new file mode 100644 index 0000000..76b4697 --- /dev/null +++ b/kookstarter/build.gradle.kts @@ -0,0 +1,88 @@ +plugins { + `java-library` + `maven-publish` + signing +} + + +java.sourceCompatibility = JavaVersion.VERSION_17 +java.targetCompatibility = JavaVersion.VERSION_17 + +val spring = "3.0.5" + +dependencies { + compileOnly("org.springframework.boot:spring-boot-starter-webflux:$spring") + + annotationProcessor("org.springframework.boot:spring-boot-configuration-processor:$spring") + + testImplementation("org.springframework.boot:spring-boot-starter-test:$spring") + testImplementation("org.springframework.boot:spring-boot-starter-webflux:$spring") +} + +tasks.test { + useJUnitPlatform() +} + +java { + setProperty("archivesBaseName", "kook-spring-boot-starter") + withJavadocJar() + withSourcesJar() +} + +publishing { + publications { + create("mavenJava") { + artifactId = "kook-spring-boot-starter" + from(components["java"]) + versionMapping { + usage("java-api") { + fromResolutionOf("runtimeClasspath") + } + usage("java-runtime") { + fromResolutionResult() + } + } + pom { + name.set("kook-spring-boot-starter") + description.set("KOOK机器人的spring-boot-starter") + url.set("https://github.com/Enaium/kook-spring-boot-starter/") + + licenses { + license { + name.set("The Apache License, Version 2.0") + url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") + } + } + developers { + developer { + id.set("enaium") + name.set("Enaium") + email.set("enaium@outlook.com") + } + } + scm { + connection.set("scm:git:https://github.com/Enaium/kook-spring-boot-starter.git") + developerConnection.set("scm:git:https://github.com/Enaium/kook-spring-boot-starter.git") + url.set("https://github.com/Enaium/kook-spring-boot-starter/") + } + } + } + } + repositories { + maven { + url = uri( + "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" + ) + credentials { + username = project.properties["ossrhUsername"].toString() + password = project.properties["ossrhPassword"].toString() + } + } + } +} + +signing { + project.properties["signing.secretKeyRingFile"]?.let { + sign(publishing.publications["mavenJava"]) + } +} \ No newline at end of file diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/KookStarter.java b/kookstarter/src/main/java/cn/enaium/kookstarter/KookStarter.java new file mode 100644 index 0000000..dd045de --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/KookStarter.java @@ -0,0 +1,60 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter; + +import cn.enaium.kookstarter.client.socket.DefaultClient; +import cn.enaium.kookstarter.configuration.KookConfiguration; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +/** + * @author Enaium + * @since 0.1.0 + */ +@ComponentScan +@EnableConfigurationProperties(KookConfiguration.class) +public class KookStarter { + + public static final Logger LOGGER = LogManager.getLogger(KookStarter.class); + + + private final DefaultClient defaultClient; + + public KookStarter(DefaultClient defaultClient) { + this.defaultClient = defaultClient; + } + + + @Bean + public CommandLineRunner run() { + return args -> { + LOGGER.info(""" + \n + _| _| _|_| _|_| _| _| _|_|_| _|_|_|_|_| _|_| _|_|_| _|_|_|_|_| _|_|_|_| _|_|_| \s + _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| \s + _|_| _| _| _| _| _|_| _|_| _| _|_|_|_| _|_|_| _| _|_|_| _|_|_| \s + _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| \s + _| _| _|_| _|_| _| _| _|_|_| _| _| _| _| _| _| _|_|_|_| _| _| \s + """); + defaultClient.connect(); + }; + } +} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/AssetAPI.java b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/AssetService.java similarity index 62% rename from core/src/main/java/cn/enaium/kook/spring/boot/starter/api/AssetAPI.java rename to kookstarter/src/main/java/cn/enaium/kookstarter/client/http/AssetService.java index 63d2441..17400bc 100644 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/AssetAPI.java +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/AssetService.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Enaium + * Copyright 2023 Enaium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,17 +14,22 @@ * limitations under the License. */ -package cn.enaium.kook.spring.boot.starter.api; +package cn.enaium.kookstarter.client.http; + +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.service.annotation.PostExchange; +import reactor.core.publisher.Mono; /** - * 媒体模块 - * * @author Enaium - * @since 0.1.0 + * @since 0.3.0 */ -public interface AssetAPI { +public interface AssetService { /** * 上传文件/图片 + * + * @since 0.3.0 */ - API ASSET_CREATE = new API(API.Method.POST, "asset/create"); + @PostExchange("asset/create") + Mono postAssetCreate(MultipartFile file); } diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/BadgeAPI.java b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/BadgeService.java similarity index 66% rename from core/src/main/java/cn/enaium/kook/spring/boot/starter/api/BadgeAPI.java rename to kookstarter/src/main/java/cn/enaium/kookstarter/client/http/BadgeService.java index b7b17a2..4a2c001 100644 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/BadgeAPI.java +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/BadgeService.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Enaium + * Copyright 2023 Enaium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,17 +14,21 @@ * limitations under the License. */ -package cn.enaium.kook.spring.boot.starter.api; +package cn.enaium.kookstarter.client.http; + +import org.springframework.web.service.annotation.GetExchange; +import reactor.core.publisher.Mono; /** - * Badge相关接口 - * * @author Enaium - * @since 0.1.0 + * @since 0.3.0 */ -public interface BadgeAPI { +public interface BadgeService { /** * 获取服务器Badge + * + * @since 0.3.0 */ - API BADGE_GUILD = new API(API.Method.GET, "badge/guild"); + @GetExchange("badge/guild") + Mono getBadgeGuild(Object... params); } diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/BlackListAPI.java b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/BlackListService.java similarity index 50% rename from core/src/main/java/cn/enaium/kook/spring/boot/starter/api/BlackListAPI.java rename to kookstarter/src/main/java/cn/enaium/kookstarter/client/http/BlackListService.java index 8614c92..1cc0731 100644 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/BlackListAPI.java +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/BlackListService.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Enaium + * Copyright 2023 Enaium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,25 +14,40 @@ * limitations under the License. */ -package cn.enaium.kook.spring.boot.starter.api; +package cn.enaium.kookstarter.client.http; + +import org.springframework.web.service.annotation.GetExchange; +import org.springframework.web.service.annotation.PostExchange; +import reactor.core.publisher.Mono; /** - * 黑名单相关接口 - * * @author Enaium - * @since 0.1.0 + * @since 0.3.0 */ -public interface BlackListAPI { +public interface BlackListService { /** - * 获取黑名单 + * 获取黑名单列表 + * + * @since 0.3.0 */ - API BLACKLIST_LIST = new API(API.Method.GET, "blacklist/list"); + @GetExchange("blacklist/list") + Mono getBlacklistList(Object... params); + + /** * 加入黑名单 + * + * @since 0.3.0 */ - API BLACKLIST_CREATE = new API(API.Method.POST, "blacklist/create"); + @PostExchange("blacklist/create") + Mono postBlacklistCreate(Object... params); + + /** * 移除黑名单 + * + * @since 0.3.0 */ - API BLACKLIST_DELETE = new API(API.Method.POST, "blacklist/delete"); -} + @PostExchange("blacklist/delete") + Mono postBlacklistDelete(Object... params); +} \ No newline at end of file diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/ChannelService.java b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/ChannelService.java new file mode 100644 index 0000000..24c8370 --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/ChannelService.java @@ -0,0 +1,134 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.client.http; + +import org.springframework.web.service.annotation.GetExchange; +import org.springframework.web.service.annotation.PostExchange; +import reactor.core.publisher.Mono; + +/** + * @author Enaium + * @since 0.3.0 + */ +public interface ChannelService { + /** + * 获取频道列表 + * + * @since 0.3.0 + */ + @GetExchange("channel/list") + Mono getChannelList(Object... params); + + + /** + * 获取频道详情 + * + * @since 0.3.0 + */ + @GetExchange("channel/view") + Mono getChannelView(Object... params); + + + /** + * 创建频道 + * + * @since 0.3.0 + */ + @PostExchange("channel/create") + Mono postChannelCreate(Object... params); + + + /** + * 编辑频道 + * + * @since 0.3.0 + */ + @PostExchange("channel/update") + Mono postChannelUpdate(Object... params); + + + /** + * 删除频道 + * + * @since 0.3.0 + */ + @PostExchange("channel/delete") + Mono postChannelDelete(Object... params); + + + /** + * 语音频道用户列表 + * + * @since 0.3.0 + */ + @GetExchange("channel/user-list") + Mono getChannelUserList(Object... params); + + + /** + * 语音频道之间移动用户 + * + * @since 0.3.0 + */ + @GetExchange("channel/move-user") + Mono postChannelMoveUser(Object... params); + + + /** + * 获取频道角色权限详情 + * + * @since 0.3.0 + */ + @GetExchange("channel-role/index") + Mono getChannelRoleIndex(Object... params); + + + /** + * 创建频道角色权限 + * + * @since 0.3.0 + */ + @PostExchange("channel-role/create") + Mono postChannelRoleCreate(Object... params); + + + /** + * 更新频道角色权限 + * + * @since 0.3.0 + */ + @PostExchange("channel-role/update") + Mono postChannelRoleUpdate(Object... params); + + + /** + * 同步频道角色权限 + * + * @since 0.3.0 + */ + @PostExchange("channel-role/sync") + Mono postChannelRoleSync(Object... params); + + + /** + * 删除频道角色权限 + * + * @since 0.3.0 + */ + @PostExchange("channel-role/delete") + Mono postChannelRoleDelete(Object... params); +} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/ChannelUserAPI.java b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/ChannelUserService.java similarity index 64% rename from core/src/main/java/cn/enaium/kook/spring/boot/starter/api/ChannelUserAPI.java rename to kookstarter/src/main/java/cn/enaium/kookstarter/client/http/ChannelUserService.java index 7e87a16..c27a255 100644 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/ChannelUserAPI.java +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/ChannelUserService.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Enaium + * Copyright 2023 Enaium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,17 +14,21 @@ * limitations under the License. */ -package cn.enaium.kook.spring.boot.starter.api; +package cn.enaium.kookstarter.client.http; + +import org.springframework.web.service.annotation.GetExchange; +import reactor.core.publisher.Mono; /** - * 频道用户相关接口 - * * @author Enaium - * @since 0.1.0 + * @since 0.3.0 */ -public interface ChannelUserAPI { +public interface ChannelUserService { /** * 根据用户id和服务器id获取用户所在语音频道 + * + * @since 0.3.0 */ - API CHANNEL_USER_GET_JOINED_CHANNEL = new API(API.Method.GET, "channel-user/get-joined-channel"); + @GetExchange("channel-user/get-joined-channel") + Mono getChannelUserGetJoinedChannel(Object... params); } diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/DirectMessageService.java b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/DirectMessageService.java new file mode 100644 index 0000000..8b837d3 --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/DirectMessageService.java @@ -0,0 +1,89 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.client.http; + +import org.springframework.web.service.annotation.GetExchange; +import org.springframework.web.service.annotation.PostExchange; +import reactor.core.publisher.Mono; + +/** + * @author Enaium + * @since 0.3.0 + */ +public interface DirectMessageService { + /** + * 获取私信聊天消息列表 + * + * @since 0.3.0 + */ + @GetExchange("direct-message/list") + Mono getDirectMessageList(Object... params); + + + /** + * 发送私信聊天消息 + * + * @since 0.3.0 + */ + @PostExchange("direct-message/create") + Mono postDirectMessageCreate(Object... params); + + + /** + * 更新私信聊天消息 + * + * @since 0.3.0 + */ + @PostExchange("direct-message/update") + Mono postDirectMessageUpdate(Object... params); + + + /** + * 删除私信聊天消息 + * + * @since 0.3.0 + */ + @PostExchange("direct-message/delete") + Mono postDirectMessageDelete(Object... params); + + + /** + * 获取频道消息某个回应的用户列表 + * + * @since 0.3.0 + */ + @GetExchange("direct-message/reaction-list") + Mono getDirectMessageReactionList(Object... params); + + + /** + * 给某个消息添加回应 + * + * @since 0.3.0 + */ + @PostExchange("direct-message/add-reaction") + Mono postDirectMessageAddReaction(Object... params); + + + /** + * 删除消息的某个回应 + * + * @since 0.3.0 + */ + @PostExchange("direct-message/delete-reaction") + Mono postDirectMessageDeleteReaction(Object... params); +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/FriendService.java b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/FriendService.java new file mode 100644 index 0000000..6e7954f --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/FriendService.java @@ -0,0 +1,62 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.client.http; + +import org.springframework.web.service.annotation.GetExchange; +import org.springframework.web.service.annotation.PostExchange; +import reactor.core.publisher.Mono; + +/** + * @author Enaium + * @since 0.3.0 + */ +public interface FriendService { + /** + * 好友列表 + * + * @since 0.3.0 + */ + @GetExchange("friend") + Mono getFriend(Object... params); + + + /** + * 好友申请 + * + * @since 0.3.0 + */ + @PostExchange("friend/request") + Mono postFriendRequest(Object... params); + + + /** + * 处理好友申请 + * + * @since 0.3.0 + */ + @PostExchange("friend/handle-request") + Mono postFriendHandleRequest(Object... params); + + + /** + * 删除好友 + * + * @since 0.3.0 + */ + @PostExchange("friend/delete") + Mono postFriendDelete(Object... params); +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/GameService.java b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/GameService.java new file mode 100644 index 0000000..1222fe1 --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/GameService.java @@ -0,0 +1,81 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.client.http; + +import org.springframework.web.service.annotation.GetExchange; +import org.springframework.web.service.annotation.PostExchange; +import reactor.core.publisher.Mono; + +/** + * @author Enaium + * @since 0.3.0 + */ +public interface GameService { + /** + * 游戏列表 + * + * @since 0.3.0 + */ + @GetExchange("game") + Mono getGame(Object... params); + + + /** + * 添加游戏 + * + * @since 0.3.0 + */ + @PostExchange("game/create") + Mono postGameCreate(Object... params); + + + /** + * 更新游戏 + * + * @since 0.3.0 + */ + @PostExchange("game/update") + Mono postGameUpdate(Object... params); + + + /** + * 删除游戏 + * + * @since 0.3.0 + */ + @PostExchange("game/delete") + Mono postGameDelete(Object... params); + + + /** + * 添加游戏/音乐记录(开始玩/听) + * + * @since 0.3.0 + */ + @PostExchange("game/activity") + Mono postGameActivity(Object... params); + + + /** + * 删除游戏/音乐记录(结束玩/听) + * + * @since 0.3.0 + */ + @PostExchange("game/delete-activity") + Mono postGameDeleteActivity(Object... params); + +} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/GatewayAPI.java b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/GatewayService.java similarity index 66% rename from core/src/main/java/cn/enaium/kook/spring/boot/starter/api/GatewayAPI.java rename to kookstarter/src/main/java/cn/enaium/kookstarter/client/http/GatewayService.java index afa7529..246e442 100644 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/GatewayAPI.java +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/GatewayService.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Enaium + * Copyright 2023 Enaium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,17 +14,21 @@ * limitations under the License. */ -package cn.enaium.kook.spring.boot.starter.api; +package cn.enaium.kookstarter.client.http; + +import org.springframework.web.service.annotation.GetExchange; +import reactor.core.publisher.Mono; /** - * Gateway 相关接口 - * * @author Enaium - * @since 0.1.0 + * @since 0.3.0 */ -public interface GatewayAPI { +public interface GatewayService { /** * 获取网关连接地址 + * + * @since 0.3.0 */ - API GATEWAY_INDEX = new API(API.Method.GET, "gateway/index"); + @GetExchange("gateway/index") + Mono getGatewayIndex(Object... params); } diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/GuildEmojiAPI.java b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/GuildEmojiService.java similarity index 50% rename from core/src/main/java/cn/enaium/kook/spring/boot/starter/api/GuildEmojiAPI.java rename to kookstarter/src/main/java/cn/enaium/kookstarter/client/http/GuildEmojiService.java index d17a6e7..c155d20 100644 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/GuildEmojiAPI.java +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/GuildEmojiService.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Enaium + * Copyright 2023 Enaium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,29 +14,47 @@ * limitations under the License. */ -package cn.enaium.kook.spring.boot.starter.api; +package cn.enaium.kookstarter.client.http; + +import org.springframework.web.service.annotation.GetExchange; +import org.springframework.web.service.annotation.PostExchange; +import reactor.core.publisher.Mono; /** - * 服务器表情相关接口 - * * @author Enaium - * @since 0.1.0 + * @since 0.3.0 */ -public interface GuildEmojiAPI { +public interface GuildEmojiService { /** * 获取服务器表情列表 + * + * @since 0.3.0 */ - API GUILD_EMOJI_LIST = new API(API.Method.GET, "guild-emoji/list"); + @GetExchange("guild-emoji/list") + Mono getGuildEmojiList(Object... params); + /** * 创建服务器表情 + * + * @since 0.3.0 */ - API GUILD_EMOJI_CREATE = new API(API.Method.POST, "guild-emoji/create"); + @PostExchange("guild-emoji/create") + Mono postGuildEmojiCreate(Object... params); + /** * 更新服务器表情 + * + * @since 0.3.0 */ - API GUILD_EMOJI_UPDATE = new API(API.Method.POST, "guild-emoji/update"); + @PostExchange("guild-emoji/update") + Mono postGuildEmojiUpdate(Object... params); + + /** * 删除服务器表情 + * + * @since 0.3.0 */ - API GUILD_EMOJI_DELETE = new API(API.Method.POST, "guild-emoji/delete"); + @PostExchange("guild-emoji/delete") + Mono postGuildEmojiDelete(Object... params); } diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/GuildRoleService.java b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/GuildRoleService.java new file mode 100644 index 0000000..5618278 --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/GuildRoleService.java @@ -0,0 +1,80 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.client.http; + +import org.springframework.web.service.annotation.GetExchange; +import org.springframework.web.service.annotation.PostExchange; +import reactor.core.publisher.Mono; + +/** + * @author Enaium + * @since 0.3.0 + */ +public interface GuildRoleService { + /** + * 获取服务器角色列表 + * + * @since 0.3.0 + */ + @GetExchange("guild-role/list") + Mono getGuildRoleList(Object... params); + + + /** + * 创建服务器角色 + * + * @since 0.3.0 + */ + @PostExchange("guild-role/create") + Mono postGuildRoleCreate(Object... params); + + + /** + * 更新服务器角色 + * + * @since 0.3.0 + */ + @PostExchange("guild-role/update") + Mono postGuildRoleUpdate(Object... params); + + + /** + * 删除服务器角色 + * + * @since 0.3.0 + */ + @PostExchange("guild-role/delete") + Mono postGuildRoleDelete(Object... params); + + + /** + * 赋予用户角色 + * + * @since 0.3.0 + */ + @PostExchange("guild-role/grant") + Mono postGuildRoleGrant(Object... params); + + + /** + * 删除用户角色 + * + * @since 0.3.0 + */ + @PostExchange("guild-role/revoke") + Mono postGuildRoleRevoke(Object... params); +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/GuildService.java b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/GuildService.java new file mode 100644 index 0000000..46ef71d --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/GuildService.java @@ -0,0 +1,116 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.client.http; + +import org.springframework.web.service.annotation.GetExchange; +import org.springframework.web.service.annotation.PostExchange; +import reactor.core.publisher.Mono; + +/** + * @author Enaium + * @since 0.3.0 + */ +public interface GuildService { + /** + * 获取当前用户加入的服务器列表 + * + * @since 0.3.0 + */ + @GetExchange("guild/list") + Mono getGuildList(Object... params); + + + /** + * 获取服务器详情 + * + * @since 0.3.0 + */ + @GetExchange("guild/view") + Mono getGuildView(Object... params); + + + /** + * 获取服务器中的用户列表 + * + * @since 0.3.0 + */ + @GetExchange("guild/user-list") + Mono getGuildUserList(Object... params); + + + /** + * 修改服务器中用户的昵称 + * + * @since 0.3.0 + */ + @PostExchange("guild/nickname") + Mono postGuildNickname(Object... params); + + + /** + * 离开服务器 + * + * @since 0.3.0 + */ + @PostExchange("guild/leave") + Mono postGuildLeave(Object... params); + + + /** + * 踢出服务器 + * + * @since 0.3.0 + */ + @PostExchange("guild/kickout") + Mono postGuildKickout(Object... params); + + + /** + * 服务器静音闭麦列表 + * + * @since 0.3.0 + */ + @GetExchange("guild-mute/list") + Mono getGuildMuteList(Object... params); + + + /** + * 添加服务器静音或闭麦 + * + * @since 0.3.0 + */ + @PostExchange("guild-mute/create") + Mono postGuildMuteCreate(Object... params); + + + /** + * 删除服务器静音或闭麦 + * + * @since 0.3.0 + */ + @PostExchange("guild-mute/delete") + Mono postGuildMuteDelete(Object... params); + + + /** + * 查询服务器的助力包历史 + * + * @since 0.3.0 + */ + @GetExchange("guild-boost/history") + Mono getGuildBoostHistory(Object... params); +} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/member/ExitedGuildMember.java b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/IntimacyService.java similarity index 52% rename from core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/member/ExitedGuildMember.java rename to kookstarter/src/main/java/cn/enaium/kookstarter/client/http/IntimacyService.java index 74b2af5..6f5edde 100644 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/member/ExitedGuildMember.java +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/IntimacyService.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Enaium + * Copyright 2023 Enaium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,29 +14,31 @@ * limitations under the License. */ -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.member; +package cn.enaium.kookstarter.client.http; -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.SystemMessageExtra; - -import java.util.Map; +import org.springframework.web.service.annotation.GetExchange; +import org.springframework.web.service.annotation.PostExchange; +import reactor.core.publisher.Mono; /** - * 服务器成员退出 - * * @author Enaium - * @since 0.1.0 + * @since 0.3.0 */ -@Listener -public class ExitedGuildMember extends SystemMessageExtra> { - public static final String TYPE = "exited_guild"; - +public interface IntimacyService { /** - * 用户 id + * 获取用户的亲密度 + * + * @since 0.3.0 */ - public String user_id; + @GetExchange("intimacy/index") + Mono getIntimacyIndex(Object... params); + + /** - * 退出服务器的事件 + * 更新用户的亲密度 + * + * @since 0.3.0 */ - public int exited_at; + @PostExchange("intimacy/update") + Mono postIntimacyUpdate(Object... params); } diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/InviteAPI.java b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/InviteService.java similarity index 53% rename from core/src/main/java/cn/enaium/kook/spring/boot/starter/api/InviteAPI.java rename to kookstarter/src/main/java/cn/enaium/kookstarter/client/http/InviteService.java index c780380..8c2f99b 100644 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/InviteAPI.java +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/InviteService.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Enaium + * Copyright 2023 Enaium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,25 +14,40 @@ * limitations under the License. */ -package cn.enaium.kook.spring.boot.starter.api; +package cn.enaium.kookstarter.client.http; + +import org.springframework.web.service.annotation.GetExchange; +import org.springframework.web.service.annotation.PostExchange; +import reactor.core.publisher.Mono; /** - * 邀请相关接口 - * * @author Enaium - * @since 0.1.0 + * @since 0.3.0 */ -public interface InviteAPI { +public interface InviteService { /** * 获取邀请列表 + * + * @since 0.3.0 */ - API INVITE_LIST = new API(API.Method.GET, "invite/list"); + @GetExchange("invite/list") + Mono getInviteList(Object... params); + + /** * 创建邀请链接 + * + * @since 0.3.0 */ - API INVITE_CREATE = new API(API.Method.POST, "invite/create"); + @PostExchange("invite/create") + Mono postInviteCreate(Object... params); + + /** * 删除邀请链接 + * + * @since 0.3.0 */ - API INVITE_DELETE = new API(API.Method.POST, "invite/delete"); + @PostExchange("invite/delete") + Mono postInviteDelete(Object... params); } diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/MessageService.java b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/MessageService.java new file mode 100644 index 0000000..5430540 --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/MessageService.java @@ -0,0 +1,98 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.client.http; + +import org.springframework.web.service.annotation.GetExchange; +import org.springframework.web.service.annotation.PostExchange; +import reactor.core.publisher.Mono; + +/** + * @author Enaium + * @since 0.3.0 + */ +public interface MessageService { + /** + * 获取频道聊天消息列表 + * + * @since 0.3.0 + */ + @GetExchange("message/list") + Mono getMessageList(Object... params); + + + /** + * 获取频道聊天消息详情 + * + * @since 0.3.0 + */ + @GetExchange("message/view") + Mono getMessageView(Object... params); + + + /** + * 发送频道聊天消息 + * + * @since 0.3.0 + */ + @PostExchange("message/create") + Mono postMessageCreate(Object... params); + + + /** + * 更新频道聊天消息 + * + * @since 0.3.0 + */ + @PostExchange("message/update") + Mono postMessageUpdate(Object... params); + + + /** + * 删除频道聊天消息 + * + * @since 0.3.0 + */ + @PostExchange("message/delete") + Mono postMessageDelete(Object... params); + + + /** + * 获取频道消息某个回应的用户列表 + * + * @since 0.3.0 + */ + @GetExchange("message/reaction-list") + Mono getMessageReactionList(Object... params); + + + /** + * 给某个消息添加回应 + * + * @since 0.3.0 + */ + @PostExchange("message/add-reaction") + Mono postMessageAddReaction(Object... params); + + + /** + * 删除消息的某个回应 + * + * @since 0.3.0 + */ + @PostExchange("message/delete-reaction") + Mono postMessageDeleteReaction(Object... params); +} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/OAuthAPI.java b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/OAuthService.java similarity index 66% rename from core/src/main/java/cn/enaium/kook/spring/boot/starter/api/OAuthAPI.java rename to kookstarter/src/main/java/cn/enaium/kookstarter/client/http/OAuthService.java index 31e7c1b..162ded6 100644 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/OAuthAPI.java +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/OAuthService.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Enaium + * Copyright 2023 Enaium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,17 +14,21 @@ * limitations under the License. */ -package cn.enaium.kook.spring.boot.starter.api; +package cn.enaium.kookstarter.client.http; + +import org.springframework.web.service.annotation.PostExchange; +import reactor.core.publisher.Mono; /** - * OAuth2.0相关接口 - * * @author Enaium - * @since 0.1.0 + * @since 0.3.0 */ -public interface OAuthAPI { +interface OAuthService { /** * 获取AccessToken + * + * @since 0.3.0 */ - API _API_OAUTH2_TOKEN = new API(API.Method.POST, "/api/oauth2/token"); + @PostExchange("oauth2/token") + Mono postApiOauth2Token(Object... params); } diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/UserChatAPI.java b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/UserChatService.java similarity index 51% rename from core/src/main/java/cn/enaium/kook/spring/boot/starter/api/UserChatAPI.java rename to kookstarter/src/main/java/cn/enaium/kookstarter/client/http/UserChatService.java index a89a2e8..4e402f9 100644 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/UserChatAPI.java +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/UserChatService.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Enaium + * Copyright 2023 Enaium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,29 +14,49 @@ * limitations under the License. */ -package cn.enaium.kook.spring.boot.starter.api; +package cn.enaium.kookstarter.client.http; + +import org.springframework.web.service.annotation.GetExchange; +import org.springframework.web.service.annotation.PostExchange; +import reactor.core.publisher.Mono; /** - * 私信聊天会话接口 - * * @author Enaium - * @since 0.1.0 + * @since 0.3.0 */ -public interface UserChatAPI { +public interface UserChatService { /** * 获取私信聊天会话列表 + * + * @since 0.3.0 */ - API USER_CHAT_LIST = new API(API.Method.GET, "user-chat/list"); + @GetExchange("user-chat/list") + Mono getUserChatList(Object... params); + + /** * 获取私信聊天会话详情 + * + * @since 0.3.0 */ - API USER_CHAT_VIEW = new API(API.Method.GET, "user-chat/view"); + @GetExchange("user-chat/view") + Mono getUserChatView(Object... params); + + /** * 创建私信聊天会话 + * + * @since 0.3.0 */ - API USER_CHAT_CREATE = new API(API.Method.POST, "user-chat/create"); + @PostExchange("user-chat/create") + Mono postUserChatCreate(Object... params); + + /** * 删除私信聊天会话 + * + * @since 0.3.0 */ - API USER_CHAT_DELETE = new API(API.Method.POST, "user-chat/delete"); + @PostExchange("user-chat/delete") + Mono postUserChatDelete(Object... params); } diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/UserAPI.java b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/UserService.java similarity index 54% rename from core/src/main/java/cn/enaium/kook/spring/boot/starter/api/UserAPI.java rename to kookstarter/src/main/java/cn/enaium/kookstarter/client/http/UserService.java index 2bc0c3a..736f520 100644 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/api/UserAPI.java +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/client/http/UserService.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Enaium + * Copyright 2023 Enaium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,25 +14,40 @@ * limitations under the License. */ -package cn.enaium.kook.spring.boot.starter.api; +package cn.enaium.kookstarter.client.http; + +import org.springframework.web.service.annotation.GetExchange; +import org.springframework.web.service.annotation.PostExchange; +import reactor.core.publisher.Mono; /** - * 用户相关接口 - * * @author Enaium - * @since 0.1.0 + * @since 0.3.0 */ -public interface UserAPI { +public interface UserService { /** * 获取当前用户信息 + * + * @since 0.3.0 */ - API USER_ME = new API(API.Method.GET, "user/me"); + @GetExchange("user/me") + Mono getUserMe(Object... params); + + /** * 获取目标用户信息 + * + * @since 0.3.0 */ - API USER_VIEW = new API(API.Method.GET, "user/view"); + @GetExchange("user/view") + Mono getUserView(Object... params); + + /** * 下线机器人 + * + * @since 0.3.0 */ - API USER_OFFLINE = new API(API.Method.POST, "user/offline"); + @PostExchange("user/offline") + Mono postUserOffline(Object... params); } diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/client/resolver/GetResolver.java b/kookstarter/src/main/java/cn/enaium/kookstarter/client/resolver/GetResolver.java new file mode 100644 index 0000000..1e48936 --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/client/resolver/GetResolver.java @@ -0,0 +1,74 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.client.resolver; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.core.MethodParameter; +import org.springframework.web.service.annotation.GetExchange; +import org.springframework.web.service.invoker.HttpRequestValues; +import org.springframework.web.service.invoker.HttpServiceArgumentResolver; + +import java.util.Map; + +import static cn.enaium.kookstarter.KookStarter.LOGGER; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class GetResolver implements HttpServiceArgumentResolver { + @Override + public boolean resolve(Object argument, MethodParameter parameter, HttpRequestValues.Builder requestValues) { + final var getExchange = parameter.getMethodAnnotation(GetExchange.class); + if (getExchange == null) { + return false; + } + + if (!argument.getClass().isArray()) { + return false; + } + + if (((Object[]) argument).length == 0) {//长度为0说明无参数 + argument = Map.of();//无参数时用空map代替 + } else { + argument = ((Object[]) argument)[0];//有参数时只取第一个参数值 + } + + + if (Map.class.isAssignableFrom(argument.getClass())) {//如果是map,就将每个键值对添加到参数中 + for (Map.Entry entry : ((Map) argument).entrySet()) { + requestValues.addRequestParameter(entry.getKey(), entry.getValue().toString()); + } + } else {//如果是其他对象,就将对象的所有字段添加到参数中 + try { + final var objectMapper = new ObjectMapper(); + final var string = objectMapper.writeValueAsString(argument); + final var fields = objectMapper.readTree(string).fields(); + while (fields.hasNext()) { + final var next = fields.next(); + requestValues.addRequestParameter(next.getKey(), next.getValue().textValue()); + } + } catch (JsonProcessingException e) { + LOGGER.error("参数处理错误"); + e.printStackTrace(); + return false; + } + } + return true; + } +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/client/resolver/PostResolver.java b/kookstarter/src/main/java/cn/enaium/kookstarter/client/resolver/PostResolver.java new file mode 100644 index 0000000..b6728d1 --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/client/resolver/PostResolver.java @@ -0,0 +1,66 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.client.resolver; + +import org.springframework.core.MethodParameter; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.core.ReactiveAdapter; +import org.springframework.core.ReactiveAdapterRegistry; +import org.springframework.util.Assert; +import org.springframework.web.service.annotation.PostExchange; +import org.springframework.web.service.invoker.HttpRequestValues; +import org.springframework.web.service.invoker.HttpServiceArgumentResolver; + +import java.util.Map; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class PostResolver implements HttpServiceArgumentResolver { + @Override + public boolean resolve(Object argument, MethodParameter parameter, HttpRequestValues.Builder requestValues) { + final var postExchange = parameter.getMethodAnnotation(PostExchange.class); + + if (postExchange == null) { + return false; + } + + if (((Object[]) argument).length == 0) { + argument = null; + } else { + argument = ((Object[]) argument)[0]; + } + + ReactiveAdapter reactiveAdapter = ReactiveAdapterRegistry.getSharedInstance().getAdapter(Map.class); + if (reactiveAdapter == null) { + requestValues.setBodyValue(argument); + } else { + MethodParameter nestedParameter = parameter.nested(); + + String message = "Async type for @RequestBody should produce value(s)"; + Assert.isTrue(!reactiveAdapter.isNoValue(), message); + Assert.isTrue(nestedParameter.getNestedParameterType() != Void.class, message); + + requestValues.setBody( + reactiveAdapter.toPublisher(argument), + ParameterizedTypeReference.forType(nestedParameter.getNestedGenericParameterType())); + } + + return true; + } +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/client/socket/DefaultClient.java b/kookstarter/src/main/java/cn/enaium/kookstarter/client/socket/DefaultClient.java new file mode 100644 index 0000000..2bca8e8 --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/client/socket/DefaultClient.java @@ -0,0 +1,75 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.client.socket; + +import cn.enaium.kookstarter.client.http.GatewayService; +import cn.enaium.kookstarter.configuration.KookConfiguration; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.socket.client.ReactorNettyWebSocketClient; +import reactor.core.scheduler.Schedulers; + +import java.net.URI; +import java.util.Map; + +import static cn.enaium.kookstarter.KookStarter.LOGGER; + +/** + * @author Enaium + * @since 0.1.0 + */ +@Component +public class DefaultClient { + + private final GatewayService gatewayService; + private final KookConfiguration configuration; + private final ApplicationEventPublisher publisher; + + public DefaultClient(GatewayService gatewayService, KookConfiguration configuration, ApplicationEventPublisher publisher) { + this.gatewayService = gatewayService; + this.configuration = configuration; + this.publisher = publisher; + } + + public void connect() { + gatewayService.getGatewayIndex(Map.of("compress", 0))//不进行zlib压缩 + .publishOn(Schedulers.boundedElastic()) + .doOnSuccess(gateway -> { + JsonNode result; + try { + result = new ObjectMapper().readValue(gateway, ObjectNode.class); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + + new ReactorNettyWebSocketClient() + .execute(URI.create(result.get("data").get("url").asText()), new DefaultHandler(configuration, publisher, this)) + .doOnError(throwable -> { + LOGGER.info("连接出现异常"); + throwable.printStackTrace(); + }).subscribe(); + }) + .doOnError(throwable -> { + LOGGER.error("获取网关连接地址失败"); + throwable.printStackTrace(); + }).subscribe(); + } +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/client/socket/DefaultHandler.java b/kookstarter/src/main/java/cn/enaium/kookstarter/client/socket/DefaultHandler.java new file mode 100644 index 0000000..3f00016 --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/client/socket/DefaultHandler.java @@ -0,0 +1,145 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.client.socket; + +import cn.enaium.kookstarter.configuration.KookConfiguration; +import cn.enaium.kookstarter.event.Event; +import cn.enaium.kookstarter.event.Events; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.core.io.buffer.DataBuffer; +import org.springframework.web.reactive.socket.WebSocketHandler; +import org.springframework.web.reactive.socket.WebSocketMessage; +import org.springframework.web.reactive.socket.WebSocketSession; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import reactor.core.scheduler.Schedulers; +import reactor.util.annotation.NonNull; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.time.Duration; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicLong; +import java.util.zip.DataFormatException; +import java.util.zip.Inflater; + +import static cn.enaium.kookstarter.KookStarter.LOGGER; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class DefaultHandler implements WebSocketHandler { + + private final KookConfiguration configuration; + private final ApplicationEventPublisher publisher; + private final DefaultClient defaultClient; + + public AtomicInteger sn = new AtomicInteger(); + + public DefaultHandler(KookConfiguration configuration, ApplicationEventPublisher publisher, DefaultClient defaultClient) { + this.configuration = configuration; + this.publisher = publisher; + this.defaultClient = defaultClient; + } + + @NonNull + @Override + public Mono handle(@NonNull WebSocketSession session) { + Flux ping = Flux.interval(Duration.ofSeconds(30)).map(i -> session.textMessage("{\"s\":2,\"sn\":" + sn.get() + "}")); + + final var input = session.receive().map(WebSocketMessage::getPayloadAsText).publishOn(Schedulers.boundedElastic()).doOnNext(message -> { + if (configuration.isShowSign()) { + LOGGER.info(message); + } + + JsonNode jsonNode; + try { + jsonNode = new ObjectMapper().readValue(message, JsonNode.class); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + + if (jsonNode.has("sn")) { + sn.set(jsonNode.get("sn").intValue()); + } + + switch (jsonNode.get("s").intValue()) { + case 1 -> {//握手成功 + LOGGER.info("连接建立成功"); + } + case 3 -> {//收到pong + + } + case 5 -> {//要求客户端断开当前连接重新连接 + LOGGER.info("服务器要求客户端断开当前连接重新连接"); + sn.set(0); + session.close().doOnSuccess(unused -> { + defaultClient.connect(); + }).subscribe(); + } + case 0 -> {//事件 + final var data = jsonNode.get("d"); + final var extra = data.get("extra"); + final var type = extra.get("type").asText(); + final Class event; + //除消息事件之外,其余都是系统事件 + if (data.get("type").intValue() == 255) {//系统事件 + event = Events.EVENTS.get(type); + } else {//消息事件 + event = Events.EVENTS.get("message_" + type); + } + + if (event == null) { + LOGGER.info("未知事件:{}", type); + return; + } + + try { + publisher.publishEvent(event.getConstructor(Object.class, Object.class).newInstance(this, message)); + } catch (InstantiationException | IllegalAccessException | InvocationTargetException | + NoSuchMethodException e) { + throw new RuntimeException(e); + } + } + } + }).then(); + return session.send(ping).and(input); + } + + + //解压zlib + private byte[] decompress(DataBuffer dataBuffer) throws IOException, DataFormatException { + Inflater inflater = new Inflater(); + final var compressedData = dataBuffer.asInputStream().readAllBytes(); + inflater.setInput(compressedData); + + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(compressedData.length); + byte[] buffer = new byte[1024]; + while (!inflater.finished()) { + int count = inflater.inflate(buffer); + outputStream.write(buffer, 0, count); + } + outputStream.close(); + + return outputStream.toByteArray(); + } +} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/server/DeletedBlockListServer.java b/kookstarter/src/main/java/cn/enaium/kookstarter/configuration/KookConfiguration.java similarity index 50% rename from core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/server/DeletedBlockListServer.java rename to kookstarter/src/main/java/cn/enaium/kookstarter/configuration/KookConfiguration.java index 098f9a6..b185d85 100644 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/data/extra/event/server/DeletedBlockListServer.java +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/configuration/KookConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Enaium + * Copyright 2023 Enaium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,31 +14,39 @@ * limitations under the License. */ -package cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.server; +package cn.enaium.kookstarter.configuration; -import cn.enaium.kook.spring.boot.starter.annotation.event.Listener; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.SystemMessageExtra; - -import java.util.Map; +import org.springframework.boot.context.properties.ConfigurationProperties; /** - * 服务器取消封禁用户 - * * @author Enaium * @since 0.1.0 */ -@Listener -public class DeletedBlockListServer extends SystemMessageExtra> { - - public static final String TYPE = "deleted_block_list"; - +@ConfigurationProperties("kook") +public class KookConfiguration { /** - * 操作人 id + * 机器人的Token */ - public String operator_id; + private String token; + /** - * 被封禁成员 id 列表 + * 收到信令时在控制台输出 */ - public Object[] user_id; -} + private boolean showSign = false; + + public String getToken() { + return token; + } + + public void setToken(String token) { + this.token = token; + } + + public boolean isShowSign() { + return showSign; + } + public void setShowSign(boolean showSign) { + this.showSign = showSign; + } +} \ No newline at end of file diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/configuration/WebClientConfiguration.java b/kookstarter/src/main/java/cn/enaium/kookstarter/configuration/WebClientConfiguration.java new file mode 100644 index 0000000..c2114ec --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/configuration/WebClientConfiguration.java @@ -0,0 +1,194 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.configuration; + +import cn.enaium.kookstarter.client.http.*; +import cn.enaium.kookstarter.client.resolver.GetResolver; +import cn.enaium.kookstarter.client.resolver.PostResolver; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatusCode; +import org.springframework.web.reactive.function.client.WebClient; +import org.springframework.web.reactive.function.client.support.WebClientAdapter; +import org.springframework.web.service.invoker.HttpServiceProxyFactory; +import reactor.core.publisher.Mono; + +/** + * @author Enaium + * @since 0.3.0 + */ +@Configuration +public class WebClientConfiguration { + + private final KookConfiguration configuration; + + public WebClientConfiguration(KookConfiguration configuration) { + this.configuration = configuration; + } + + @Bean + WebClient webClient() { + return WebClient.builder().baseUrl("https://www.kookapp.cn/api/v3/") + .defaultStatusHandler(HttpStatusCode::isError, clientResponse -> Mono.empty()) + .defaultHeader(HttpHeaders.AUTHORIZATION, "Bot " + configuration.getToken()).build(); + } + + @Bean + HttpServiceProxyFactory httpServiceProxyFactory(WebClient webClient) { + return HttpServiceProxyFactory.builder(WebClientAdapter.forClient(webClient)) + .customArgumentResolver(new GetResolver()) + .customArgumentResolver(new PostResolver()) + .build(); + } + + /** + * @since 0.3.0 + */ + @Bean + AssetService AssetService(HttpServiceProxyFactory httpServiceProxyFactory) { + return httpServiceProxyFactory.createClient(AssetService.class); + } + + /** + * @since 0.3.0 + */ + @Bean + BadgeService BadgeService(HttpServiceProxyFactory httpServiceProxyFactory) { + return httpServiceProxyFactory.createClient(BadgeService.class); + } + + /** + * @since 0.3.0 + */ + @Bean + BlackListService BlackListService(HttpServiceProxyFactory httpServiceProxyFactory) { + return httpServiceProxyFactory.createClient(BlackListService.class); + } + + /** + * @since 0.3.0 + */ + @Bean + ChannelService ChannelService(HttpServiceProxyFactory httpServiceProxyFactory) { + return httpServiceProxyFactory.createClient(ChannelService.class); + } + + /** + * @since 0.3.0 + */ + @Bean + ChannelUserService ChannelUserService(HttpServiceProxyFactory httpServiceProxyFactory) { + return httpServiceProxyFactory.createClient(ChannelUserService.class); + } + + /** + * @since 0.3.0 + */ + @Bean + DirectMessageService DirectMessageService(HttpServiceProxyFactory httpServiceProxyFactory) { + return httpServiceProxyFactory.createClient(DirectMessageService.class); + } + + /** + * @since 0.3.0 + */ + @Bean + FriendService FriendService(HttpServiceProxyFactory httpServiceProxyFactory) { + return httpServiceProxyFactory.createClient(FriendService.class); + } + + /** + * @since 0.3.0 + */ + @Bean + GameService GameService(HttpServiceProxyFactory httpServiceProxyFactory) { + return httpServiceProxyFactory.createClient(GameService.class); + } + + /** + * @since 0.3.0 + */ + @Bean + GatewayService GatewayService(HttpServiceProxyFactory httpServiceProxyFactory) { + return httpServiceProxyFactory.createClient(GatewayService.class); + } + + /** + * @since 0.3.0 + */ + @Bean + GuildEmojiService GuildEmojiService(HttpServiceProxyFactory httpServiceProxyFactory) { + return httpServiceProxyFactory.createClient(GuildEmojiService.class); + } + + /** + * @since 0.3.0 + */ + @Bean + GuildRoleService GuildRoleService(HttpServiceProxyFactory httpServiceProxyFactory) { + return httpServiceProxyFactory.createClient(GuildRoleService.class); + } + + /** + * @since 0.3.0 + */ + @Bean + GuildService GuildService(HttpServiceProxyFactory httpServiceProxyFactory) { + return httpServiceProxyFactory.createClient(GuildService.class); + } + + /** + * @since 0.3.0 + */ + @Bean + IntimacyService IntimacyService(HttpServiceProxyFactory httpServiceProxyFactory) { + return httpServiceProxyFactory.createClient(IntimacyService.class); + } + + /** + * @since 0.3.0 + */ + @Bean + InviteService InviteService(HttpServiceProxyFactory httpServiceProxyFactory) { + return httpServiceProxyFactory.createClient(InviteService.class); + } + + /** + * @since 0.3.0 + */ + @Bean + MessageService MessageService(HttpServiceProxyFactory httpServiceProxyFactory) { + return httpServiceProxyFactory.createClient(MessageService.class); + } + + /** + * @since 0.3.0 + */ + @Bean + UserChatService UserChatService(HttpServiceProxyFactory httpServiceProxyFactory) { + return httpServiceProxyFactory.createClient(UserChatService.class); + } + + /** + * @since 0.3.0 + */ + @Bean + UserService UserService(HttpServiceProxyFactory httpServiceProxyFactory) { + return httpServiceProxyFactory.createClient(UserService.class); + } +} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/object/KMarkdownObject.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/AddedBlockList.java similarity index 71% rename from core/src/main/java/cn/enaium/kook/spring/boot/starter/model/object/KMarkdownObject.java rename to kookstarter/src/main/java/cn/enaium/kookstarter/event/AddedBlockList.java index 8473600..213f013 100644 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/object/KMarkdownObject.java +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/AddedBlockList.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Enaium + * Copyright 2023 Enaium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,14 +14,14 @@ * limitations under the License. */ -package cn.enaium.kook.spring.boot.starter.model.object; +package cn.enaium.kookstarter.event; /** * @author Enaium - * @since 0.1.0 + * @since 0.3.0 */ -public class KMarkdownObject { - public String raw_content; - public Object[] mention_part; - public Object[] mention_role_part; +public class AddedBlockList extends Event { + public AddedBlockList(Object source, Object metadata) { + super(source, metadata); + } } diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/AddedChannel.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/AddedChannel.java new file mode 100644 index 0000000..2887787 --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/AddedChannel.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class AddedChannel extends Event { + public AddedChannel(Object source, Object metadata) { + super(source, metadata); + } +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/AddedEmoji.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/AddedEmoji.java new file mode 100644 index 0000000..e09f29a --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/AddedEmoji.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class AddedEmoji extends Event { + public AddedEmoji(Object source, Object metadata) { + super(source, metadata); + } +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/AddedReaction.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/AddedReaction.java new file mode 100644 index 0000000..5d77c80 --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/AddedReaction.java @@ -0,0 +1,28 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class AddedReaction extends Event { + public AddedReaction(Object source, Object metadata) { + super(source, metadata); + } +} + diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/AddedRole.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/AddedRole.java new file mode 100644 index 0000000..a8690dc --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/AddedRole.java @@ -0,0 +1,28 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class AddedRole extends Event { + public AddedRole(Object source, Object metadata) { + super(source, metadata); + } +} + diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/AudioEvent.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/AudioEvent.java new file mode 100644 index 0000000..4b6217f --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/AudioEvent.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class AudioEvent extends Event { + public AudioEvent(Object source, Object metadata) { + super(source, metadata); + } +} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/Sign.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/CardEvent.java similarity index 73% rename from core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/Sign.java rename to kookstarter/src/main/java/cn/enaium/kookstarter/event/CardEvent.java index 27ba306..fe2c5be 100644 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/sign/Sign.java +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/CardEvent.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Enaium + * Copyright 2023 Enaium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,14 +14,14 @@ * limitations under the License. */ -package cn.enaium.kook.spring.boot.starter.model.sign; +package cn.enaium.kookstarter.event; /** * @author Enaium - * @since 0.1.0 + * @since 0.3.0 */ -public class Sign { - public int s; - public T d; - public int sn; +public class CardEvent extends Event { + public CardEvent(Object source, Object metadata) { + super(source, metadata); + } } diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/DeletedBlockList.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/DeletedBlockList.java new file mode 100644 index 0000000..9293848 --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/DeletedBlockList.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class DeletedBlockList extends Event { + public DeletedBlockList(Object source, Object metadata) { + super(source, metadata); + } +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/DeletedChannel.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/DeletedChannel.java new file mode 100644 index 0000000..eb9b4c9 --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/DeletedChannel.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class DeletedChannel extends Event { + public DeletedChannel(Object source, Object metadata) { + super(source, metadata); + } +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/DeletedGuild.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/DeletedGuild.java new file mode 100644 index 0000000..13e1b3e --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/DeletedGuild.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class DeletedGuild extends Event { + public DeletedGuild(Object source, Object metadata) { + super(source, metadata); + } +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/DeletedMessage.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/DeletedMessage.java new file mode 100644 index 0000000..ee0b1fc --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/DeletedMessage.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class DeletedMessage extends Event { + public DeletedMessage(Object source, Object metadata) { + super(source, metadata); + } +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/DeletedPrivateMessage.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/DeletedPrivateMessage.java new file mode 100644 index 0000000..f5fd94b --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/DeletedPrivateMessage.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class DeletedPrivateMessage extends Event { + public DeletedPrivateMessage(Object source, Object metadata) { + super(source, metadata); + } +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/DeletedReaction.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/DeletedReaction.java new file mode 100644 index 0000000..623739e --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/DeletedReaction.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class DeletedReaction extends Event { + public DeletedReaction(Object source, Object metadata) { + super(source, metadata); + } +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/DeletedRole.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/DeletedRole.java new file mode 100644 index 0000000..2266946 --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/DeletedRole.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class DeletedRole extends Event { + public DeletedRole(Object source, Object metadata) { + super(source, metadata); + } +} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/annotation/event/Register.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/Event.java similarity index 58% rename from core/src/main/java/cn/enaium/kook/spring/boot/starter/annotation/event/Register.java rename to kookstarter/src/main/java/cn/enaium/kookstarter/event/Event.java index f637b2b..5495254 100644 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/annotation/event/Register.java +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/Event.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Enaium + * Copyright 2023 Enaium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,20 +14,26 @@ * limitations under the License. */ -package cn.enaium.kook.spring.boot.starter.annotation.event; - -import org.springframework.stereotype.Component; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; +package cn.enaium.kookstarter.event; /** * @author Enaium + * @since 0.3.0 */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -@Component -public @interface Register { +public class Event { + private final Object source; + private final Object metadata; + + public Event(Object source, Object metadata) { + this.source = source; + this.metadata = metadata; + } + + public Object getSource() { + return source; + } + + public Object getMetadata() { + return metadata; + } } diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/Events.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/Events.java new file mode 100644 index 0000000..c3478e4 --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/Events.java @@ -0,0 +1,73 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +import java.util.Map; + +import static java.util.Map.entry; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class Events { + public static final Map> EVENTS = + Map.ofEntries( + entry("added_reaction", AddedReaction.class), + entry("deleted_reaction", DeletedReaction.class), + entry("updated_message", UpdatedMessage.class), + entry("deleted_message", DeletedMessage.class), + entry("added_channel", AddedChannel.class), + entry("updated_channel", UpdatedChannel.class), + entry("deleted_channel", DeletedChannel.class), + entry("pinned_message", PinnedMessage.class), + entry("unpinned_message", UnpinnedMessage.class), + entry("updated_private_message", UpdatedPrivateMessage.class), + entry("deleted_private_message", DeletedPrivateMessage.class), + entry("private_added_reaction", PrivateAddedReaction.class), + entry("private_deleted_reaction", PrivateDeletedReaction.class), + entry("joined_guild", JoinedGuild.class), + entry("exited_guild", ExitedGuild.class), + entry("updated_guild_member", UpdatedGuildMember.class), + entry("guild_member_online", GuildMemberOnline.class), + entry("guild_member_offline", GuildMemberOffline.class), + entry("added_role", AddedRole.class), + entry("deleted_role", DeletedRole.class), + entry("updated_role", UpdatedRole.class), + entry("updated_guild", UpdatedGuild.class), + entry("deleted_guild", DeletedGuild.class), + entry("added_block_list", AddedBlockList.class), + entry("deleted_block_list", DeletedBlockList.class), + entry("added_emoji", AddedEmoji.class), + entry("removed_emoji", RemovedEmoji.class), + entry("updated_emoji", UpdatedEmoji.class), + entry("joined_channel", JoinedChannel.class), + entry("exited_channel", ExitedChannel.class), + entry("user_updated", UserUpdated.class), + entry("self_joined_guild", SelfJoinedGuild.class), + entry("self_exited_guild", SelfExitedGuild.class), + entry("message_btn_click", MessageBtnClick.class), + entry("message_1", TextEvent.class), + entry("message_2", ImageEvent.class), + entry("message_3", VideoEvent.class), + entry("message_4", FileEvent.class), + entry("message_8", AudioEvent.class), + entry("message_9", KMarkdownEvent.class), + entry("message_10", CardEvent.class), + entry("message_12", ImageAnimationEvent.class) + ); +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/ExitedChannel.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/ExitedChannel.java new file mode 100644 index 0000000..a2c9767 --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/ExitedChannel.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class ExitedChannel extends Event { + public ExitedChannel(Object source, Object metadata) { + super(source, metadata); + } +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/ExitedGuild.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/ExitedGuild.java new file mode 100644 index 0000000..247ca82 --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/ExitedGuild.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class ExitedGuild extends Event { + public ExitedGuild(Object source, Object metadata) { + super(source, metadata); + } +} diff --git a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/result/GatewayResult.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/FileEvent.java similarity index 73% rename from core/src/main/java/cn/enaium/kook/spring/boot/starter/model/result/GatewayResult.java rename to kookstarter/src/main/java/cn/enaium/kookstarter/event/FileEvent.java index 952d117..8a0df07 100644 --- a/core/src/main/java/cn/enaium/kook/spring/boot/starter/model/result/GatewayResult.java +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/FileEvent.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Enaium + * Copyright 2023 Enaium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,15 +14,14 @@ * limitations under the License. */ -package cn.enaium.kook.spring.boot.starter.model.result; +package cn.enaium.kookstarter.event; /** * @author Enaium - * @since 0.1.0 + * @since 0.3.0 */ -public class GatewayResult { - /** - * 网关的连接地址 - */ - public String url; +public class FileEvent extends Event { + public FileEvent(Object source, Object metadata) { + super(source, metadata); + } } diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/GuildMemberOffline.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/GuildMemberOffline.java new file mode 100644 index 0000000..e792527 --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/GuildMemberOffline.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class GuildMemberOffline extends Event { + public GuildMemberOffline(Object source, Object metadata) { + super(source, metadata); + } +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/GuildMemberOnline.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/GuildMemberOnline.java new file mode 100644 index 0000000..b8a9618 --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/GuildMemberOnline.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class GuildMemberOnline extends Event { + public GuildMemberOnline(Object source, Object metadata) { + super(source, metadata); + } +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/ImageAnimationEvent.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/ImageAnimationEvent.java new file mode 100644 index 0000000..ba58591 --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/ImageAnimationEvent.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class ImageAnimationEvent extends Event { + public ImageAnimationEvent(Object source, Object metadata) { + super(source, metadata); + } +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/ImageEvent.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/ImageEvent.java new file mode 100644 index 0000000..350861b --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/ImageEvent.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class ImageEvent extends Event { + public ImageEvent(Object source, Object metadata) { + super(source, metadata); + } +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/JoinedChannel.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/JoinedChannel.java new file mode 100644 index 0000000..8b79fb2 --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/JoinedChannel.java @@ -0,0 +1,28 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class JoinedChannel extends Event { + public JoinedChannel(Object source, Object metadata) { + super(source, metadata); + } +} + diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/JoinedGuild.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/JoinedGuild.java new file mode 100644 index 0000000..ec880c8 --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/JoinedGuild.java @@ -0,0 +1,28 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class JoinedGuild extends Event { + public JoinedGuild(Object source, Object metadata) { + super(source, metadata); + } +} + diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/KMarkdownEvent.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/KMarkdownEvent.java new file mode 100644 index 0000000..a6d1314 --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/KMarkdownEvent.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class KMarkdownEvent extends Event { + public KMarkdownEvent(Object source, Object metadata) { + super(source, metadata); + } +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/MessageBtnClick.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/MessageBtnClick.java new file mode 100644 index 0000000..8cae077 --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/MessageBtnClick.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class MessageBtnClick extends Event { + public MessageBtnClick(Object source, Object metadata) { + super(source, metadata); + } +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/PinnedMessage.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/PinnedMessage.java new file mode 100644 index 0000000..e3deee7 --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/PinnedMessage.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class PinnedMessage extends Event { + public PinnedMessage(Object source, Object metadata) { + super(source, metadata); + } +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/PrivateAddedReaction.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/PrivateAddedReaction.java new file mode 100644 index 0000000..ca3b1ef --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/PrivateAddedReaction.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class PrivateAddedReaction extends Event { + public PrivateAddedReaction(Object source, Object metadata) { + super(source, metadata); + } +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/PrivateDeletedReaction.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/PrivateDeletedReaction.java new file mode 100644 index 0000000..cdf3ecc --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/PrivateDeletedReaction.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class PrivateDeletedReaction extends Event { + public PrivateDeletedReaction(Object source, Object metadata) { + super(source, metadata); + } +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/RemovedEmoji.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/RemovedEmoji.java new file mode 100644 index 0000000..fd9e8fa --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/RemovedEmoji.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class RemovedEmoji extends Event { + public RemovedEmoji(Object source, Object metadata) { + super(source, metadata); + } +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/SelfExitedGuild.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/SelfExitedGuild.java new file mode 100644 index 0000000..288046b --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/SelfExitedGuild.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class SelfExitedGuild extends Event { + public SelfExitedGuild(Object source, Object metadata) { + super(source, metadata); + } +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/SelfJoinedGuild.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/SelfJoinedGuild.java new file mode 100644 index 0000000..5590faa --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/SelfJoinedGuild.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class SelfJoinedGuild extends Event { + public SelfJoinedGuild(Object source, Object metadata) { + super(source, metadata); + } +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/TextEvent.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/TextEvent.java new file mode 100644 index 0000000..9163236 --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/TextEvent.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class TextEvent extends Event { + public TextEvent(Object source, Object metadata) { + super(source, metadata); + } +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/UnpinnedMessage.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/UnpinnedMessage.java new file mode 100644 index 0000000..cef1bbf --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/UnpinnedMessage.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class UnpinnedMessage extends Event { + public UnpinnedMessage(Object source, Object metadata) { + super(source, metadata); + } +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/UpdatedChannel.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/UpdatedChannel.java new file mode 100644 index 0000000..f317f99 --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/UpdatedChannel.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class UpdatedChannel extends Event { + public UpdatedChannel(Object source, Object metadata) { + super(source, metadata); + } +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/UpdatedEmoji.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/UpdatedEmoji.java new file mode 100644 index 0000000..f280444 --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/UpdatedEmoji.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class UpdatedEmoji extends Event { + public UpdatedEmoji(Object source, Object metadata) { + super(source, metadata); + } +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/UpdatedGuild.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/UpdatedGuild.java new file mode 100644 index 0000000..2a8e3e2 --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/UpdatedGuild.java @@ -0,0 +1,28 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class UpdatedGuild extends Event { + public UpdatedGuild(Object source, Object metadata) { + super(source, metadata); + } +} + diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/UpdatedGuildMember.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/UpdatedGuildMember.java new file mode 100644 index 0000000..fe16c1e --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/UpdatedGuildMember.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class UpdatedGuildMember extends Event { + public UpdatedGuildMember(Object source, Object metadata) { + super(source, metadata); + } +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/UpdatedMessage.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/UpdatedMessage.java new file mode 100644 index 0000000..417aec8 --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/UpdatedMessage.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class UpdatedMessage extends Event { + public UpdatedMessage(Object source, Object metadata) { + super(source, metadata); + } +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/UpdatedPrivateMessage.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/UpdatedPrivateMessage.java new file mode 100644 index 0000000..e5aa48b --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/UpdatedPrivateMessage.java @@ -0,0 +1,28 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class UpdatedPrivateMessage extends Event { + public UpdatedPrivateMessage(Object source, Object metadata) { + super(source, metadata); + } +} + diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/UpdatedRole.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/UpdatedRole.java new file mode 100644 index 0000000..cb92fe0 --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/UpdatedRole.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class UpdatedRole extends Event { + public UpdatedRole(Object source, Object metadata) { + super(source, metadata); + } +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/UserUpdated.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/UserUpdated.java new file mode 100644 index 0000000..54e46cc --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/UserUpdated.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class UserUpdated extends Event { + public UserUpdated(Object source, Object metadata) { + super(source, metadata); + } +} diff --git a/kookstarter/src/main/java/cn/enaium/kookstarter/event/VideoEvent.java b/kookstarter/src/main/java/cn/enaium/kookstarter/event/VideoEvent.java new file mode 100644 index 0000000..bafdbc4 --- /dev/null +++ b/kookstarter/src/main/java/cn/enaium/kookstarter/event/VideoEvent.java @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.event; + +/** + * @author Enaium + * @since 0.3.0 + */ +public class VideoEvent extends Event { + public VideoEvent(Object source, Object metadata) { + super(source, metadata); + } +} diff --git a/kookstarter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/kookstarter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000..913d83c --- /dev/null +++ b/kookstarter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +cn.enaium.kookstarter.KookStarter \ No newline at end of file diff --git a/kookstarter/src/test/java/cn/enaium/kookstarter/client/http/ServiceTest.java b/kookstarter/src/test/java/cn/enaium/kookstarter/client/http/ServiceTest.java new file mode 100644 index 0000000..e3a84f3 --- /dev/null +++ b/kookstarter/src/test/java/cn/enaium/kookstarter/client/http/ServiceTest.java @@ -0,0 +1,100 @@ +/* + * Copyright 2023 Enaium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.enaium.kookstarter.client.http; + +import cn.enaium.kookstarter.client.resolver.GetResolver; +import cn.enaium.kookstarter.client.resolver.PostResolver; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.springframework.web.reactive.function.client.WebClient; +import org.springframework.web.reactive.function.client.support.WebClientAdapter; +import org.springframework.web.service.invoker.HttpServiceProxyFactory; +import reactor.core.publisher.Mono; +import reactor.netty.http.server.HttpServer; + +import java.util.Map; +import java.util.Objects; + +/** + * @author Enaium + */ +class ServiceTest { + + HttpServiceProxyFactory factory = HttpServiceProxyFactory.builder(WebClientAdapter.forClient(WebClient.builder().baseUrl("http://localhost:8888").build())) + .customArgumentResolver(new GetResolver()) + .customArgumentResolver(new PostResolver()) + .build(); + + + @BeforeAll + public static void server() { + HttpServer.create().host("localhost").port(8888).route(routes -> { + routes + .get("/**", ((httpServerRequest, httpServerResponse) -> httpServerResponse.sendString(Mono.just(httpServerRequest.uri()).map(uri -> { + if (uri.contains("?")) { + return uri.split("\\?")[1]; + } else { + return ""; + } + })))) + .post("/**", (httpServerRequest, httpServerResponse) -> httpServerResponse.sendString(httpServerRequest.receive().asString())); + }).bind().block(); + } + + @Test + public void getNoParam() { + Assertions.assertNull(factory.createClient(GatewayService.class).getGatewayIndex().block()); + } + + @Test + public void getMapParam() { + final var block = factory.createClient(GatewayService.class).getGatewayIndex(Map.of("key1", "value1", "key2", "value2")).block(); + Assertions.assertTrue(Objects.equals(block, "key1=value1&key2=value2") || Objects.equals(block, "key2=value2&key1=value1")); + } + + @Test + public void getOParam() { + Assertions.assertEquals( + factory.createClient(GatewayService.class).getGatewayIndex(new O("value1", "value2")).block(), + "key1=value1&key2=value2" + ); + } + + @Test + public void postNoBody() { + Assertions.assertNull( + factory.createClient(MessageService.class).postMessageCreate().block() + ); + } + + @Test + public void postMapBody() { + final var block = factory.createClient(MessageService.class).postMessageCreate(Map.of("key1", "value1", "key2", "value2")).block(); + Assertions.assertTrue(Objects.equals(block, "{\"key1\":\"value1\",\"key2\":\"value2\"}") || Objects.equals(block, "{\"key2\":\"value2\",\"key1\":\"value1\"}")); + } + + @Test + public void postOBody() { + final var block = factory.createClient(MessageService.class).postMessageCreate(new O("value1", "value2")).block(); + Assertions.assertTrue(Objects.equals(block, "{\"key1\":\"value1\",\"key2\":\"value2\"}") || Objects.equals(block, "{\"key2\":\"value2\",\"key1\":\"value1\"}")); + } + + private record O(String key1, String key2) { + + } +} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index e3c81d1..0000000 --- a/settings.gradle +++ /dev/null @@ -1,4 +0,0 @@ -rootProject.name = 'kook-spring-boot-starter' -include 'core' -include 'test' - diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..6b8b42e --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,3 @@ +rootProject.name = "kookstarter" +include("kookstarter") +include("kookstarter-sample") diff --git a/test/README.md b/test/README.md deleted file mode 100644 index a6dc3cc..0000000 --- a/test/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# 测试例子 - -记得在`resources`下创建一个`application.properties`文件 - -```properties -kook.token=机器人的Token -``` \ No newline at end of file diff --git a/test/build.gradle b/test/build.gradle deleted file mode 100644 index bfa7fff..0000000 --- a/test/build.gradle +++ /dev/null @@ -1,27 +0,0 @@ -plugins { - id 'org.springframework.boot' version '2.7.2' - id 'io.spring.dependency-management' version '1.0.12.RELEASE' - id 'java' -} - -group 'cn.enaium' -version '1.0-SNAPSHOT' - -repositories { - mavenCentral() -} - -repositories { - mavenCentral() -} - -dependencies { - implementation 'org.springframework.boot:spring-boot-starter' - implementation project(':core') - - testImplementation 'org.springframework.boot:spring-boot-starter-test' -} - -test { - useJUnitPlatform() -} diff --git a/test/src/main/java/cn/enaium/kook/spring/boot/starter/TestApplication.java b/test/src/main/java/cn/enaium/kook/spring/boot/starter/TestApplication.java deleted file mode 100644 index 1863bce..0000000 --- a/test/src/main/java/cn/enaium/kook/spring/boot/starter/TestApplication.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.enaium.kook.spring.boot.starter; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * @author Enaium - */ -@SpringBootApplication -public class TestApplication { - public static void main(String[] args) { - SpringApplication.run(TestApplication.class, args); - } -} diff --git a/test/src/main/java/cn/enaium/kook/spring/boot/starter/events/TestEvent.java b/test/src/main/java/cn/enaium/kook/spring/boot/starter/events/TestEvent.java deleted file mode 100644 index b281f11..0000000 --- a/test/src/main/java/cn/enaium/kook/spring/boot/starter/events/TestEvent.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter.events; - -import cn.enaium.kook.spring.boot.starter.annotation.event.Event; -import cn.enaium.kook.spring.boot.starter.annotation.event.Register; -import cn.enaium.kook.spring.boot.starter.api.DirectMessageAPI; -import cn.enaium.kook.spring.boot.starter.api.MessageAPI; -import cn.enaium.kook.spring.boot.starter.model.constant.ChannelType; -import cn.enaium.kook.spring.boot.starter.model.constant.MessageType; -import cn.enaium.kook.spring.boot.starter.model.sign.data.EventData; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.message.ImageAnimationMessage; -import cn.enaium.kook.spring.boot.starter.model.sign.data.extra.event.message.KMarkdownMessage; -import cn.enaium.kook.spring.boot.starter.util.HttpUtil; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.Map; - -/** - * 一个例子,不管对方说什么只会说Hello - * - * @author Enaium - */ -@Register -public class TestEvent { - - private final Logger logger = LogManager.getLogger(TestEvent.class); - - @Autowired - public HttpUtil httpUtil; - - @Event(KMarkdownMessage.class) - public void event(EventData kMarkdownMessageEventData) { - //判断是不是机器人,如果不判断机器人发出的消息话,也会进入这个事件,从而导致死循环 - if (kMarkdownMessageEventData.extra.author.bot) { - return; - } - - Map kmarkdown = kMarkdownMessageEventData.extra.kmarkdown; - Object raw_content = kmarkdown.get("raw_content"); - logger.info("对方说了:{}", raw_content); - if (kMarkdownMessageEventData.channel_type.equals(ChannelType.PERSON)) { - //私信 - logger.info("说了Hello 返回:{}", httpUtil.send(DirectMessageAPI.DIRECT_MESSAGE_CREATE.setBody( - Map.of( - "type", MessageType.KMARKDOWN, - "target_id", kMarkdownMessageEventData.author_id, - "content", "**Hello**" - ) - ))); - } else if (kMarkdownMessageEventData.channel_type.equals(ChannelType.GROUP)) { - //频道 - logger.info("说了Hello 返回:{}", httpUtil.send(MessageAPI.MESSAGE_CREATE.setBody( - Map.of( - "type", MessageType.KMARKDOWN, - "target_id", kMarkdownMessageEventData.target_id, - "content", "**Hello**" - ) - ))); - } - } - - @Event(ImageAnimationMessage.class) - public void imageAnimation(EventData imageAnimationMessageEventData) { - logger.info(imageAnimationMessageEventData.extra.kmarkdown); - } -} diff --git a/test/src/test/java/cn/enaium/kook/spring/boot/starter/CreateAssetsTest.java b/test/src/test/java/cn/enaium/kook/spring/boot/starter/CreateAssetsTest.java deleted file mode 100644 index 701e017..0000000 --- a/test/src/test/java/cn/enaium/kook/spring/boot/starter/CreateAssetsTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2022 Enaium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.enaium.kook.spring.boot.starter; - -import cn.enaium.kook.spring.boot.starter.api.AssetAPI; -import cn.enaium.kook.spring.boot.starter.util.HttpUtil; -import kong.unirest.HttpResponse; -import kong.unirest.Unirest; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; - -import java.io.File; - -/** - * @author Enaium - * @since 0.2.0 - */ -@SpringBootTest -class CreateAssetsTest { - - private final Logger logger = LogManager.getLogger(CreateAssetsTest.class); - @Autowired - private HttpUtil httpUtil; - - @Test - public void create() { - logger.info(httpUtil.request(AssetAPI.ASSET_CREATE).field("file", new File(System.getProperty("user.dir"), "README.md")).asString().getBody()); - } -} \ No newline at end of file