Compare commits

...

20 Commits

Author SHA1 Message Date
e5788822ed feat: add retry configuration and optimization running lifecycle 2025-03-26 19:12:56 +08:00
d9d3bb2a5b fix: change help command format 2025-02-04 14:18:03 +08:00
6eea40e134 docs: change the wrong version number 2025-02-04 14:05:31 +08:00
d2cb0728cd docs: change the wrong version number 2025-02-04 14:05:15 +08:00
c6c119da39 fix: fix cannot use escape char to be the command prefix 2025-02-04 14:01:07 +08:00
2bdb11622f ci: change version 2025-02-04 13:53:31 +08:00
3e1b71c149 feat: add changeable command prefix 2025-02-04 13:50:52 +08:00
9b9b55ed85 ci: change version to 1.6 release 2025-02-01 04:26:58 +08:00
8b729519b0 fix: fix json message part cannot be serialized correctly 2025-02-01 04:26:03 +08:00
57177510d5 feat: add some type 2024-12-20 11:31:12 +08:00
ad2d5a085e fix: change default max packet size to 6553600 2024-11-09 21:15:19 +08:00
wzp
94937e990e fix: fix cn.wzpmc.plugins.JavaPlugin::saveDefaultConfig method overwrite the configuration file bug 2024-10-23 10:45:51 +08:00
wzp
6526af0437 fix: fix cn.wzpmc.plugins.JavaPlugin::saveDefaultConfig method overwrite the configuration file bug 2024-10-23 10:44:02 +08:00
wzp
dc1f35ca0d docs: adding document 2024-10-23 10:42:57 +08:00
wzp
bc57932783 ci: change version to 1.0.5 2024-10-10 10:47:24 +08:00
wzp
4c5fc7a673 feat: adding configuration loader 2024-10-10 09:40:45 +08:00
wzp
a8c46c6ef7 deps: change snakeyaml to api 2024-10-10 09:29:10 +08:00
wzp
f8cbc50a6a feat: adding essence event
fix: Fixed the BUG of automatically agreeing to add group applications
2024-10-10 08:53:42 +08:00
wzp
eb44c6bab4 ci: change the ways to include dependencies in the module of api 2024-09-08 14:10:44 +08:00
wzp
61d3a8280e docs: fix using the releases repository cannot build bug (using public group repository) 2024-09-02 20:00:41 +08:00
74 changed files with 30226 additions and 75 deletions

6
.idea/ApifoxUploaderProjectSetting.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ApifoxUploaderProjectSetting">
<option name="apiAccessToken" value="APS-QWelq6AktQqByilNWeWZgKoPT7a4ml1d" />
</component>
</project>

View File

@ -1 +1 @@
1.0.3 1.0.7

3
.idea/gradle.xml generated
View File

@ -4,8 +4,9 @@
<component name="GradleSettings"> <component name="GradleSettings">
<option name="linkedExternalProjectsSettings"> <option name="linkedExternalProjectsSettings">
<GradleProjectSettings> <GradleProjectSettings>
<option name="distributionType" value="LOCAL" />
<option name="externalProjectPath" value="$PROJECT_DIR$" /> <option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="" /> <option name="gradleHome" value="$USER_HOME$/.sdkman/candidates/gradle/current" />
<option name="modules"> <option name="modules">
<set> <set>
<option value="$PROJECT_DIR$" /> <option value="$PROJECT_DIR$" />

View File

@ -21,5 +21,25 @@
<option name="name" value="maven" /> <option name="name" value="maven" />
<option name="url" value="https://libraries.minecraft.net" /> <option name="url" value="https://libraries.minecraft.net" />
</remote-repository> </remote-repository>
<remote-repository>
<option name="id" value="maven" />
<option name="name" value="maven" />
<option name="url" value="https://maven.aliyun.com/repository/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="maven2" />
<option name="name" value="maven2" />
<option name="url" value="https://maven.aliyun.com/repository/central" />
</remote-repository>
<remote-repository>
<option name="id" value="maven3" />
<option name="name" value="maven3" />
<option name="url" value="https://maven.aliyun.com/repository/gradle-plugin" />
</remote-repository>
<remote-repository>
<option name="id" value="MavenLocal" />
<option name="name" value="MavenLocal" />
<option name="url" value="file:/$MAVEN_REPOSITORY$" />
</remote-repository>
</component> </component>
</project> </project>

8
.idea/modules/MyBot.iml generated Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="AdditionalModuleElements">
<content url="file://$MODULE_DIR$/../.." dumb="true">
<excludeFolder url="file://$MODULE_DIR$/../../run" />
</content>
</component>
</module>

View File

@ -39,7 +39,7 @@
<repositories> <repositories>
<repository> <repository>
<id>wzpmc-maven-releases</id> <id>wzpmc-maven-releases</id>
<url>https://wzpmc.cn:90/repository/maven-releases</url> <url>https://wzpmc.cn:90/repository/maven-public</url>
</repository> </repository>
</repositories> </repositories>
``` ```
@ -50,7 +50,7 @@
```groovy ```groovy
repositories { repositories {
maven { maven {
url "https://wzpmc.cn:90/repository/maven-releases" url "https://wzpmc.cn:90/repository/maven-public"
} }
} }
``` ```
@ -59,7 +59,7 @@ repositories {
```kotlin ```kotlin
repositories { repositories {
maven { maven {
url = uri("https://wzpmc.cn:90/repository/maven-releases") url = uri("https://wzpmc.cn:90/repository/maven-public")
} }
} }
``` ```

View File

@ -39,7 +39,7 @@ In your `pom.xml`, add the following repository configuration:
<repositories> <repositories>
<repository> <repository>
<id>wzpmc-maven-releases</id> <id>wzpmc-maven-releases</id>
<url>https://wzpmc.cn:90/repository/maven-releases</url> <url>https://wzpmc.cn:90/repository/maven-public</url>
</repository> </repository>
</repositories> </repositories>
``` ```
@ -50,7 +50,7 @@ In your `pom.xml`, add the following repository configuration:
```groovy ```groovy
repositories { repositories {
maven { maven {
url "https://wzpmc.cn:90/repository/maven-releases" url "https://wzpmc.cn:90/repository/maven-public"
} }
} }
``` ```
@ -59,7 +59,7 @@ repositories {
```kotlin ```kotlin
repositories { repositories {
maven { maven {
url = uri("https://wzpmc.cn:90/repository/maven-releases") url = uri("https://wzpmc.cn:90/repository/maven-public")
} }
} }
``` ```

View File

@ -7,14 +7,14 @@ val projectArtifactId: String by extra
val projectVersion: String by extra val projectVersion: String by extra
plugins { plugins {
id("java") id("java-library")
id("com.github.johnrengelman.shadow") version "8.1.1" id("com.github.johnrengelman.shadow") version "8.1.1"
} }
allprojects { allprojects {
apply(plugin = "java") apply(plugin = "java-library")
val groupName by extra("cn.wzpmc") val groupName by extra("cn.wzpmc")
val projectArtifactId by extra("my-bot") val projectArtifactId by extra("my-bot")
val projectVersion by extra("1.0.3") val projectVersion by extra("1.0.7-SNAPSHOT")
repositories { repositories {
mavenCentral() mavenCentral()
maven("https://libraries.minecraft.net") maven("https://libraries.minecraft.net")
@ -24,13 +24,14 @@ allprojects {
compileOnly("org.projectlombok:lombok:1.18.34") compileOnly("org.projectlombok:lombok:1.18.34")
annotationProcessor("org.projectlombok:lombok:1.18.34") annotationProcessor("org.projectlombok:lombok:1.18.34")
// https://mvnrepository.com/artifact/com.alibaba.fastjson2/fastjson2 // https://mvnrepository.com/artifact/com.alibaba.fastjson2/fastjson2
implementation("com.alibaba.fastjson2:fastjson2:2.0.52") api("com.alibaba.fastjson2:fastjson2:2.0.52")
implementation("com.mojang:brigadier:1.0.18") api("com.mojang:brigadier:1.0.18")
// https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api // https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api
implementation("org.apache.logging.log4j:log4j-api:2.23.1") api("org.apache.logging.log4j:log4j-api:2.23.1")
testImplementation(platform("org.junit:junit-bom:5.10.0")) testImplementation(platform("org.junit:junit-bom:5.10.0"))
testImplementation("org.junit.jupiter:junit-jupiter") testImplementation("org.junit.jupiter:junit-jupiter")
// https://mvnrepository.com/artifact/org.yaml/snakeyaml
api("org.yaml:snakeyaml:2.2")
} }
tasks.compileJava { tasks.compileJava {
options.encoding = "UTF-8" options.encoding = "UTF-8"
@ -48,14 +49,12 @@ dependencies {
exclude(group = "org.apache.logging.log4j", module = "log4j-core") exclude(group = "org.apache.logging.log4j", module = "log4j-core")
exclude(group = "org.apache.logging.log4j", module = "log4j-api") exclude(group = "org.apache.logging.log4j", module = "log4j-api")
} }
// https://mvnrepository.com/artifact/io.netty/netty-all
implementation("io.netty:netty-all:4.1.112.Final")
// https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core // https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core
implementation("org.apache.logging.log4j:log4j-core:2.23.1") implementation("org.apache.logging.log4j:log4j-core:2.23.1")
// https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-jul // https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-jul
implementation("org.apache.logging.log4j:log4j-jul:2.23.1") implementation("org.apache.logging.log4j:log4j-jul:2.23.1")
// https://mvnrepository.com/artifact/org.yaml/snakeyaml // https://mvnrepository.com/artifact/io.netty/netty-all
implementation("org.yaml:snakeyaml:2.2") implementation("io.netty:netty-all:4.1.112.Final")
// https://mvnrepository.com/artifact/org.jline/jline // https://mvnrepository.com/artifact/org.jline/jline
implementation("org.jline:jline-terminal:3.26.3") implementation("org.jline:jline-terminal:3.26.3")
implementation("org.jline:jline-reader:3.26.3") implementation("org.jline:jline-reader:3.26.3")

2
docs/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.idea/
node_modules/

5
docs/.idea/.gitignore generated vendored Normal file
View File

@ -0,0 +1,5 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/

12
docs/.idea/docs.iml generated Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

8
docs/.idea/modules.xml generated Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/docs.iml" filepath="$PROJECT_DIR$/.idea/docs.iml" />
</modules>
</component>
</project>

6
docs/.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

1
docs/.vitepress/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
cache/

View File

@ -0,0 +1,269 @@
import {
useMediaQuery
} from "./chunk-WVCZVGU2.js";
import {
computed,
ref,
shallowRef,
watch
} from "./chunk-XIDTNVOX.js";
// node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/index.js
import "D:/ProjectsAfter240630/Java/Frameworks/MyBot/docs/node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/styles/fonts.css";
// node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/without-fonts.js
import "D:/ProjectsAfter240630/Java/Frameworks/MyBot/docs/node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/styles/vars.css";
import "D:/ProjectsAfter240630/Java/Frameworks/MyBot/docs/node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/styles/base.css";
import "D:/ProjectsAfter240630/Java/Frameworks/MyBot/docs/node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/styles/icons.css";
import "D:/ProjectsAfter240630/Java/Frameworks/MyBot/docs/node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/styles/utils.css";
import "D:/ProjectsAfter240630/Java/Frameworks/MyBot/docs/node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/styles/components/custom-block.css";
import "D:/ProjectsAfter240630/Java/Frameworks/MyBot/docs/node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/styles/components/vp-code.css";
import "D:/ProjectsAfter240630/Java/Frameworks/MyBot/docs/node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/styles/components/vp-code-group.css";
import "D:/ProjectsAfter240630/Java/Frameworks/MyBot/docs/node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/styles/components/vp-doc.css";
import "D:/ProjectsAfter240630/Java/Frameworks/MyBot/docs/node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/styles/components/vp-sponsor.css";
import VPBadge from "D:/ProjectsAfter240630/Java/Frameworks/MyBot/docs/node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/components/VPBadge.vue";
import Layout from "D:/ProjectsAfter240630/Java/Frameworks/MyBot/docs/node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/Layout.vue";
import { default as default2 } from "D:/ProjectsAfter240630/Java/Frameworks/MyBot/docs/node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/components/VPBadge.vue";
import { default as default3 } from "D:/ProjectsAfter240630/Java/Frameworks/MyBot/docs/node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/components/VPImage.vue";
import { default as default4 } from "D:/ProjectsAfter240630/Java/Frameworks/MyBot/docs/node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/components/VPButton.vue";
import { default as default5 } from "D:/ProjectsAfter240630/Java/Frameworks/MyBot/docs/node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/components/VPHomeContent.vue";
import { default as default6 } from "D:/ProjectsAfter240630/Java/Frameworks/MyBot/docs/node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/components/VPHomeHero.vue";
import { default as default7 } from "D:/ProjectsAfter240630/Java/Frameworks/MyBot/docs/node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/components/VPHomeFeatures.vue";
import { default as default8 } from "D:/ProjectsAfter240630/Java/Frameworks/MyBot/docs/node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/components/VPHomeSponsors.vue";
import { default as default9 } from "D:/ProjectsAfter240630/Java/Frameworks/MyBot/docs/node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/components/VPLink.vue";
import { default as default10 } from "D:/ProjectsAfter240630/Java/Frameworks/MyBot/docs/node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/components/VPDocAsideSponsors.vue";
import { default as default11 } from "D:/ProjectsAfter240630/Java/Frameworks/MyBot/docs/node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/components/VPSocialLink.vue";
import { default as default12 } from "D:/ProjectsAfter240630/Java/Frameworks/MyBot/docs/node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/components/VPSocialLinks.vue";
import { default as default13 } from "D:/ProjectsAfter240630/Java/Frameworks/MyBot/docs/node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/components/VPSponsors.vue";
import { default as default14 } from "D:/ProjectsAfter240630/Java/Frameworks/MyBot/docs/node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/components/VPTeamPage.vue";
import { default as default15 } from "D:/ProjectsAfter240630/Java/Frameworks/MyBot/docs/node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/components/VPTeamPageTitle.vue";
import { default as default16 } from "D:/ProjectsAfter240630/Java/Frameworks/MyBot/docs/node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/components/VPTeamPageSection.vue";
import { default as default17 } from "D:/ProjectsAfter240630/Java/Frameworks/MyBot/docs/node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/components/VPTeamMembers.vue";
// node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/support/utils.js
import { withBase } from "vitepress";
// node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/composables/data.js
import { useData as useData$ } from "vitepress";
var useData = useData$;
// node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/support/utils.js
function ensureStartingSlash(path) {
return /^\//.test(path) ? path : `/${path}`;
}
// node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/support/sidebar.js
function getSidebar(_sidebar, path) {
if (Array.isArray(_sidebar))
return addBase(_sidebar);
if (_sidebar == null)
return [];
path = ensureStartingSlash(path);
const dir = Object.keys(_sidebar).sort((a, b) => {
return b.split("/").length - a.split("/").length;
}).find((dir2) => {
return path.startsWith(ensureStartingSlash(dir2));
});
const sidebar = dir ? _sidebar[dir] : [];
return Array.isArray(sidebar) ? addBase(sidebar) : addBase(sidebar.items, sidebar.base);
}
function getSidebarGroups(sidebar) {
const groups = [];
let lastGroupIndex = 0;
for (const index in sidebar) {
const item = sidebar[index];
if (item.items) {
lastGroupIndex = groups.push(item);
continue;
}
if (!groups[lastGroupIndex]) {
groups.push({ items: [] });
}
groups[lastGroupIndex].items.push(item);
}
return groups;
}
function addBase(items, _base) {
return [...items].map((_item) => {
const item = { ..._item };
const base = item.base || _base;
if (base && item.link)
item.link = base + item.link;
if (item.items)
item.items = addBase(item.items, base);
return item;
});
}
// node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/composables/sidebar.js
function useSidebar() {
const { frontmatter, page, theme: theme2 } = useData();
const is960 = useMediaQuery("(min-width: 960px)");
const isOpen = ref(false);
const _sidebar = computed(() => {
const sidebarConfig = theme2.value.sidebar;
const relativePath = page.value.relativePath;
return sidebarConfig ? getSidebar(sidebarConfig, relativePath) : [];
});
const sidebar = ref(_sidebar.value);
watch(_sidebar, (next, prev) => {
if (JSON.stringify(next) !== JSON.stringify(prev))
sidebar.value = _sidebar.value;
});
const hasSidebar = computed(() => {
return frontmatter.value.sidebar !== false && sidebar.value.length > 0 && frontmatter.value.layout !== "home";
});
const leftAside = computed(() => {
if (hasAside)
return frontmatter.value.aside == null ? theme2.value.aside === "left" : frontmatter.value.aside === "left";
return false;
});
const hasAside = computed(() => {
if (frontmatter.value.layout === "home")
return false;
if (frontmatter.value.aside != null)
return !!frontmatter.value.aside;
return theme2.value.aside !== false;
});
const isSidebarEnabled = computed(() => hasSidebar.value && is960.value);
const sidebarGroups = computed(() => {
return hasSidebar.value ? getSidebarGroups(sidebar.value) : [];
});
function open() {
isOpen.value = true;
}
function close() {
isOpen.value = false;
}
function toggle() {
isOpen.value ? close() : open();
}
return {
isOpen,
sidebar,
sidebarGroups,
hasSidebar,
hasAside,
leftAside,
isSidebarEnabled,
open,
close,
toggle
};
}
// node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/composables/local-nav.js
import { onContentUpdated } from "vitepress";
// node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/composables/outline.js
import { getScrollOffset } from "vitepress";
var resolvedHeaders = [];
function getHeaders(range) {
const headers = [
...document.querySelectorAll(".VPDoc :where(h1,h2,h3,h4,h5,h6)")
].filter((el) => el.id && el.hasChildNodes()).map((el) => {
const level = Number(el.tagName[1]);
return {
element: el,
title: serializeHeader(el),
link: "#" + el.id,
level
};
});
return resolveHeaders(headers, range);
}
function serializeHeader(h) {
let ret = "";
for (const node of h.childNodes) {
if (node.nodeType === 1) {
if (node.classList.contains("VPBadge") || node.classList.contains("header-anchor") || node.classList.contains("ignore-header")) {
continue;
}
ret += node.textContent;
} else if (node.nodeType === 3) {
ret += node.textContent;
}
}
return ret.trim();
}
function resolveHeaders(headers, range) {
if (range === false) {
return [];
}
const levelsRange = (typeof range === "object" && !Array.isArray(range) ? range.level : range) || 2;
const [high, low] = typeof levelsRange === "number" ? [levelsRange, levelsRange] : levelsRange === "deep" ? [2, 6] : levelsRange;
return buildTree(headers, high, low);
}
function buildTree(data, min, max) {
resolvedHeaders.length = 0;
const result = [];
const stack = [];
data.forEach((item) => {
const node = { ...item, children: [] };
let parent = stack[stack.length - 1];
while (parent && parent.level >= node.level) {
stack.pop();
parent = stack[stack.length - 1];
}
if (node.element.classList.contains("ignore-header") || parent && "shouldIgnore" in parent) {
stack.push({ level: node.level, shouldIgnore: true });
return;
}
if (node.level > max || node.level < min)
return;
resolvedHeaders.push({ element: node.element, link: node.link });
if (parent)
parent.children.push(node);
else
result.push(node);
stack.push(node);
});
return result;
}
// node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/composables/local-nav.js
function useLocalNav() {
const { theme: theme2, frontmatter } = useData();
const headers = shallowRef([]);
const hasLocalNav = computed(() => {
return headers.value.length > 0;
});
onContentUpdated(() => {
headers.value = getHeaders(frontmatter.value.outline ?? theme2.value.outline);
});
return {
headers,
hasLocalNav
};
}
// node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/without-fonts.js
var theme = {
Layout,
enhanceApp: ({ app }) => {
app.component("Badge", VPBadge);
}
};
var without_fonts_default = theme;
export {
default2 as VPBadge,
default4 as VPButton,
default10 as VPDocAsideSponsors,
default5 as VPHomeContent,
default7 as VPHomeFeatures,
default6 as VPHomeHero,
default8 as VPHomeSponsors,
default3 as VPImage,
default9 as VPLink,
default11 as VPSocialLink,
default12 as VPSocialLinks,
default13 as VPSponsors,
default17 as VPTeamMembers,
default14 as VPTeamPage,
default16 as VPTeamPageSection,
default15 as VPTeamPageTitle,
without_fonts_default as default,
useLocalNav,
useSidebar
};
//# sourceMappingURL=@theme_index.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,40 @@
{
"hash": "30a63267",
"configHash": "2c9c0d33",
"lockfileHash": "de33837a",
"browserHash": "7755b019",
"optimized": {
"vue": {
"src": "../../../node_modules/.pnpm/vue@3.5.11/node_modules/vue/dist/vue.runtime.esm-bundler.js",
"file": "vue.js",
"fileHash": "f71e9ed4",
"needsInterop": false
},
"vitepress > @vue/devtools-api": {
"src": "../../../node_modules/.pnpm/@vue+devtools-api@7.4.6/node_modules/@vue/devtools-api/dist/index.js",
"file": "vitepress___@vue_devtools-api.js",
"fileHash": "e96d8db2",
"needsInterop": false
},
"vitepress > @vueuse/core": {
"src": "../../../node_modules/.pnpm/@vueuse+core@11.1.0_vue@3.5.11/node_modules/@vueuse/core/index.mjs",
"file": "vitepress___@vueuse_core.js",
"fileHash": "692684da",
"needsInterop": false
},
"@theme/index": {
"src": "../../../node_modules/.pnpm/vitepress@1.4.0_@algolia+client-search@4.24.0_postcss@8.4.47_search-insights@2.17.2/node_modules/vitepress/dist/client/theme-default/index.js",
"file": "@theme_index.js",
"fileHash": "9599b31e",
"needsInterop": false
}
},
"chunks": {
"chunk-WVCZVGU2": {
"file": "chunk-WVCZVGU2.js"
},
"chunk-XIDTNVOX": {
"file": "chunk-XIDTNVOX.js"
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,3 @@
{
"type": "module"
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,567 @@
import {
DefaultMagicKeysAliasMap,
StorageSerializers,
TransitionPresets,
assert,
breakpointsAntDesign,
breakpointsBootstrapV5,
breakpointsMasterCss,
breakpointsPrimeFlex,
breakpointsQuasar,
breakpointsSematic,
breakpointsTailwind,
breakpointsVuetify,
breakpointsVuetifyV2,
breakpointsVuetifyV3,
bypassFilter,
camelize,
clamp,
cloneFnJSON,
computedAsync,
computedEager,
computedInject,
computedWithControl,
containsProp,
controlledRef,
createEventHook,
createFetch,
createFilterWrapper,
createGlobalState,
createInjectionState,
createReusableTemplate,
createSharedComposable,
createSingletonPromise,
createTemplatePromise,
createUnrefFn,
customStorageEventName,
debounceFilter,
defaultDocument,
defaultLocation,
defaultNavigator,
defaultWindow,
directiveHooks,
executeTransition,
extendRef,
formatDate,
formatTimeAgo,
get,
getLifeCycleTarget,
getSSRHandler,
hasOwn,
hyphenate,
identity,
increaseWithUnit,
injectLocal,
invoke,
isClient,
isDef,
isDefined,
isIOS,
isObject,
isWorker,
makeDestructurable,
mapGamepadToXbox360Controller,
noop,
normalizeDate,
notNullish,
now,
objectEntries,
objectOmit,
objectPick,
onClickOutside,
onKeyDown,
onKeyPressed,
onKeyStroke,
onKeyUp,
onLongPress,
onStartTyping,
pausableFilter,
promiseTimeout,
provideLocal,
rand,
reactify,
reactifyObject,
reactiveComputed,
reactiveOmit,
reactivePick,
refAutoReset,
refDebounced,
refDefault,
refThrottled,
refWithControl,
resolveRef,
resolveUnref,
set,
setSSRHandler,
syncRef,
syncRefs,
templateRef,
throttleFilter,
timestamp,
toReactive,
toRef,
toRefs,
toValue,
tryOnBeforeMount,
tryOnBeforeUnmount,
tryOnMounted,
tryOnScopeDispose,
tryOnUnmounted,
unrefElement,
until,
useActiveElement,
useAnimate,
useArrayDifference,
useArrayEvery,
useArrayFilter,
useArrayFind,
useArrayFindIndex,
useArrayFindLast,
useArrayIncludes,
useArrayJoin,
useArrayMap,
useArrayReduce,
useArraySome,
useArrayUnique,
useAsyncQueue,
useAsyncState,
useBase64,
useBattery,
useBluetooth,
useBreakpoints,
useBroadcastChannel,
useBrowserLocation,
useCached,
useClipboard,
useClipboardItems,
useCloned,
useColorMode,
useConfirmDialog,
useCounter,
useCssVar,
useCurrentElement,
useCycleList,
useDark,
useDateFormat,
useDebounceFn,
useDebouncedRefHistory,
useDeviceMotion,
useDeviceOrientation,
useDevicePixelRatio,
useDevicesList,
useDisplayMedia,
useDocumentVisibility,
useDraggable,
useDropZone,
useElementBounding,
useElementByPoint,
useElementHover,
useElementSize,
useElementVisibility,
useEventBus,
useEventListener,
useEventSource,
useEyeDropper,
useFavicon,
useFetch,
useFileDialog,
useFileSystemAccess,
useFocus,
useFocusWithin,
useFps,
useFullscreen,
useGamepad,
useGeolocation,
useIdle,
useImage,
useInfiniteScroll,
useIntersectionObserver,
useInterval,
useIntervalFn,
useKeyModifier,
useLastChanged,
useLocalStorage,
useMagicKeys,
useManualRefHistory,
useMediaControls,
useMediaQuery,
useMemoize,
useMemory,
useMounted,
useMouse,
useMouseInElement,
useMousePressed,
useMutationObserver,
useNavigatorLanguage,
useNetwork,
useNow,
useObjectUrl,
useOffsetPagination,
useOnline,
usePageLeave,
useParallax,
useParentElement,
usePerformanceObserver,
usePermission,
usePointer,
usePointerLock,
usePointerSwipe,
usePreferredColorScheme,
usePreferredContrast,
usePreferredDark,
usePreferredLanguages,
usePreferredReducedMotion,
usePrevious,
useRafFn,
useRefHistory,
useResizeObserver,
useScreenOrientation,
useScreenSafeArea,
useScriptTag,
useScroll,
useScrollLock,
useSessionStorage,
useShare,
useSorted,
useSpeechRecognition,
useSpeechSynthesis,
useStepper,
useStorage,
useStorageAsync,
useStyleTag,
useSupported,
useSwipe,
useTemplateRefsList,
useTextDirection,
useTextSelection,
useTextareaAutosize,
useThrottleFn,
useThrottledRefHistory,
useTimeAgo,
useTimeout,
useTimeoutFn,
useTimeoutPoll,
useTimestamp,
useTitle,
useToNumber,
useToString,
useToggle,
useTransition,
useUrlSearchParams,
useUserMedia,
useVModel,
useVModels,
useVibrate,
useVirtualList,
useWakeLock,
useWebNotification,
useWebSocket,
useWebWorker,
useWebWorkerFn,
useWindowFocus,
useWindowScroll,
useWindowSize,
watchArray,
watchAtMost,
watchDebounced,
watchDeep,
watchIgnorable,
watchImmediate,
watchOnce,
watchPausable,
watchThrottled,
watchTriggerable,
watchWithFilter,
whenever
} from "./chunk-WVCZVGU2.js";
import "./chunk-XIDTNVOX.js";
export {
DefaultMagicKeysAliasMap,
StorageSerializers,
TransitionPresets,
assert,
computedAsync as asyncComputed,
refAutoReset as autoResetRef,
breakpointsAntDesign,
breakpointsBootstrapV5,
breakpointsMasterCss,
breakpointsPrimeFlex,
breakpointsQuasar,
breakpointsSematic,
breakpointsTailwind,
breakpointsVuetify,
breakpointsVuetifyV2,
breakpointsVuetifyV3,
bypassFilter,
camelize,
clamp,
cloneFnJSON,
computedAsync,
computedEager,
computedInject,
computedWithControl,
containsProp,
computedWithControl as controlledComputed,
controlledRef,
createEventHook,
createFetch,
createFilterWrapper,
createGlobalState,
createInjectionState,
reactify as createReactiveFn,
createReusableTemplate,
createSharedComposable,
createSingletonPromise,
createTemplatePromise,
createUnrefFn,
customStorageEventName,
debounceFilter,
refDebounced as debouncedRef,
watchDebounced as debouncedWatch,
defaultDocument,
defaultLocation,
defaultNavigator,
defaultWindow,
directiveHooks,
computedEager as eagerComputed,
executeTransition,
extendRef,
formatDate,
formatTimeAgo,
get,
getLifeCycleTarget,
getSSRHandler,
hasOwn,
hyphenate,
identity,
watchIgnorable as ignorableWatch,
increaseWithUnit,
injectLocal,
invoke,
isClient,
isDef,
isDefined,
isIOS,
isObject,
isWorker,
makeDestructurable,
mapGamepadToXbox360Controller,
noop,
normalizeDate,
notNullish,
now,
objectEntries,
objectOmit,
objectPick,
onClickOutside,
onKeyDown,
onKeyPressed,
onKeyStroke,
onKeyUp,
onLongPress,
onStartTyping,
pausableFilter,
watchPausable as pausableWatch,
promiseTimeout,
provideLocal,
rand,
reactify,
reactifyObject,
reactiveComputed,
reactiveOmit,
reactivePick,
refAutoReset,
refDebounced,
refDefault,
refThrottled,
refWithControl,
resolveRef,
resolveUnref,
set,
setSSRHandler,
syncRef,
syncRefs,
templateRef,
throttleFilter,
refThrottled as throttledRef,
watchThrottled as throttledWatch,
timestamp,
toReactive,
toRef,
toRefs,
toValue,
tryOnBeforeMount,
tryOnBeforeUnmount,
tryOnMounted,
tryOnScopeDispose,
tryOnUnmounted,
unrefElement,
until,
useActiveElement,
useAnimate,
useArrayDifference,
useArrayEvery,
useArrayFilter,
useArrayFind,
useArrayFindIndex,
useArrayFindLast,
useArrayIncludes,
useArrayJoin,
useArrayMap,
useArrayReduce,
useArraySome,
useArrayUnique,
useAsyncQueue,
useAsyncState,
useBase64,
useBattery,
useBluetooth,
useBreakpoints,
useBroadcastChannel,
useBrowserLocation,
useCached,
useClipboard,
useClipboardItems,
useCloned,
useColorMode,
useConfirmDialog,
useCounter,
useCssVar,
useCurrentElement,
useCycleList,
useDark,
useDateFormat,
refDebounced as useDebounce,
useDebounceFn,
useDebouncedRefHistory,
useDeviceMotion,
useDeviceOrientation,
useDevicePixelRatio,
useDevicesList,
useDisplayMedia,
useDocumentVisibility,
useDraggable,
useDropZone,
useElementBounding,
useElementByPoint,
useElementHover,
useElementSize,
useElementVisibility,
useEventBus,
useEventListener,
useEventSource,
useEyeDropper,
useFavicon,
useFetch,
useFileDialog,
useFileSystemAccess,
useFocus,
useFocusWithin,
useFps,
useFullscreen,
useGamepad,
useGeolocation,
useIdle,
useImage,
useInfiniteScroll,
useIntersectionObserver,
useInterval,
useIntervalFn,
useKeyModifier,
useLastChanged,
useLocalStorage,
useMagicKeys,
useManualRefHistory,
useMediaControls,
useMediaQuery,
useMemoize,
useMemory,
useMounted,
useMouse,
useMouseInElement,
useMousePressed,
useMutationObserver,
useNavigatorLanguage,
useNetwork,
useNow,
useObjectUrl,
useOffsetPagination,
useOnline,
usePageLeave,
useParallax,
useParentElement,
usePerformanceObserver,
usePermission,
usePointer,
usePointerLock,
usePointerSwipe,
usePreferredColorScheme,
usePreferredContrast,
usePreferredDark,
usePreferredLanguages,
usePreferredReducedMotion,
usePrevious,
useRafFn,
useRefHistory,
useResizeObserver,
useScreenOrientation,
useScreenSafeArea,
useScriptTag,
useScroll,
useScrollLock,
useSessionStorage,
useShare,
useSorted,
useSpeechRecognition,
useSpeechSynthesis,
useStepper,
useStorage,
useStorageAsync,
useStyleTag,
useSupported,
useSwipe,
useTemplateRefsList,
useTextDirection,
useTextSelection,
useTextareaAutosize,
refThrottled as useThrottle,
useThrottleFn,
useThrottledRefHistory,
useTimeAgo,
useTimeout,
useTimeoutFn,
useTimeoutPoll,
useTimestamp,
useTitle,
useToNumber,
useToString,
useToggle,
useTransition,
useUrlSearchParams,
useUserMedia,
useVModel,
useVModels,
useVibrate,
useVirtualList,
useWakeLock,
useWebNotification,
useWebSocket,
useWebWorker,
useWebWorkerFn,
useWindowFocus,
useWindowScroll,
useWindowSize,
watchArray,
watchAtMost,
watchDebounced,
watchDeep,
watchIgnorable,
watchImmediate,
watchOnce,
watchPausable,
watchThrottled,
watchTriggerable,
watchWithFilter,
whenever
};
//# sourceMappingURL=vitepress___@vueuse_core.js.map

View File

@ -0,0 +1,7 @@
{
"version": 3,
"sources": [],
"sourcesContent": [],
"mappings": "",
"names": []
}

343
docs/.vitepress/cache/deps/vue.js vendored Normal file
View File

@ -0,0 +1,343 @@
import {
BaseTransition,
BaseTransitionPropsValidators,
Comment,
DeprecationTypes,
EffectScope,
ErrorCodes,
ErrorTypeStrings,
Fragment,
KeepAlive,
ReactiveEffect,
Static,
Suspense,
Teleport,
Text,
TrackOpTypes,
Transition,
TransitionGroup,
TriggerOpTypes,
VueElement,
assertNumber,
callWithAsyncErrorHandling,
callWithErrorHandling,
camelize,
capitalize,
cloneVNode,
compatUtils,
compile,
computed,
createApp,
createBaseVNode,
createBlock,
createCommentVNode,
createElementBlock,
createHydrationRenderer,
createPropsRestProxy,
createRenderer,
createSSRApp,
createSlots,
createStaticVNode,
createTextVNode,
createVNode,
customRef,
defineAsyncComponent,
defineComponent,
defineCustomElement,
defineEmits,
defineExpose,
defineModel,
defineOptions,
defineProps,
defineSSRCustomElement,
defineSlots,
devtools,
effect,
effectScope,
getCurrentInstance,
getCurrentScope,
getCurrentWatcher,
getTransitionRawChildren,
guardReactiveProps,
h,
handleError,
hasInjectionContext,
hydrate,
hydrateOnIdle,
hydrateOnInteraction,
hydrateOnMediaQuery,
hydrateOnVisible,
initCustomFormatter,
initDirectivesForSSR,
inject,
isMemoSame,
isProxy,
isReactive,
isReadonly,
isRef,
isRuntimeOnly,
isShallow,
isVNode,
markRaw,
mergeDefaults,
mergeModels,
mergeProps,
nextTick,
normalizeClass,
normalizeProps,
normalizeStyle,
onActivated,
onBeforeMount,
onBeforeUnmount,
onBeforeUpdate,
onDeactivated,
onErrorCaptured,
onMounted,
onRenderTracked,
onRenderTriggered,
onScopeDispose,
onServerPrefetch,
onUnmounted,
onUpdated,
onWatcherCleanup,
openBlock,
popScopeId,
provide,
proxyRefs,
pushScopeId,
queuePostFlushCb,
reactive,
readonly,
ref,
registerRuntimeCompiler,
render,
renderList,
renderSlot,
resolveComponent,
resolveDirective,
resolveDynamicComponent,
resolveFilter,
resolveTransitionHooks,
setBlockTracking,
setDevtoolsHook,
setTransitionHooks,
shallowReactive,
shallowReadonly,
shallowRef,
ssrContextKey,
ssrUtils,
stop,
toDisplayString,
toHandlerKey,
toHandlers,
toRaw,
toRef,
toRefs,
toValue,
transformVNodeArgs,
triggerRef,
unref,
useAttrs,
useCssModule,
useCssVars,
useHost,
useId,
useModel,
useSSRContext,
useShadowRoot,
useSlots,
useTemplateRef,
useTransitionState,
vModelCheckbox,
vModelDynamic,
vModelRadio,
vModelSelect,
vModelText,
vShow,
version,
warn,
watch,
watchEffect,
watchPostEffect,
watchSyncEffect,
withAsyncContext,
withCtx,
withDefaults,
withDirectives,
withKeys,
withMemo,
withModifiers,
withScopeId
} from "./chunk-XIDTNVOX.js";
export {
BaseTransition,
BaseTransitionPropsValidators,
Comment,
DeprecationTypes,
EffectScope,
ErrorCodes,
ErrorTypeStrings,
Fragment,
KeepAlive,
ReactiveEffect,
Static,
Suspense,
Teleport,
Text,
TrackOpTypes,
Transition,
TransitionGroup,
TriggerOpTypes,
VueElement,
assertNumber,
callWithAsyncErrorHandling,
callWithErrorHandling,
camelize,
capitalize,
cloneVNode,
compatUtils,
compile,
computed,
createApp,
createBlock,
createCommentVNode,
createElementBlock,
createBaseVNode as createElementVNode,
createHydrationRenderer,
createPropsRestProxy,
createRenderer,
createSSRApp,
createSlots,
createStaticVNode,
createTextVNode,
createVNode,
customRef,
defineAsyncComponent,
defineComponent,
defineCustomElement,
defineEmits,
defineExpose,
defineModel,
defineOptions,
defineProps,
defineSSRCustomElement,
defineSlots,
devtools,
effect,
effectScope,
getCurrentInstance,
getCurrentScope,
getCurrentWatcher,
getTransitionRawChildren,
guardReactiveProps,
h,
handleError,
hasInjectionContext,
hydrate,
hydrateOnIdle,
hydrateOnInteraction,
hydrateOnMediaQuery,
hydrateOnVisible,
initCustomFormatter,
initDirectivesForSSR,
inject,
isMemoSame,
isProxy,
isReactive,
isReadonly,
isRef,
isRuntimeOnly,
isShallow,
isVNode,
markRaw,
mergeDefaults,
mergeModels,
mergeProps,
nextTick,
normalizeClass,
normalizeProps,
normalizeStyle,
onActivated,
onBeforeMount,
onBeforeUnmount,
onBeforeUpdate,
onDeactivated,
onErrorCaptured,
onMounted,
onRenderTracked,
onRenderTriggered,
onScopeDispose,
onServerPrefetch,
onUnmounted,
onUpdated,
onWatcherCleanup,
openBlock,
popScopeId,
provide,
proxyRefs,
pushScopeId,
queuePostFlushCb,
reactive,
readonly,
ref,
registerRuntimeCompiler,
render,
renderList,
renderSlot,
resolveComponent,
resolveDirective,
resolveDynamicComponent,
resolveFilter,
resolveTransitionHooks,
setBlockTracking,
setDevtoolsHook,
setTransitionHooks,
shallowReactive,
shallowReadonly,
shallowRef,
ssrContextKey,
ssrUtils,
stop,
toDisplayString,
toHandlerKey,
toHandlers,
toRaw,
toRef,
toRefs,
toValue,
transformVNodeArgs,
triggerRef,
unref,
useAttrs,
useCssModule,
useCssVars,
useHost,
useId,
useModel,
useSSRContext,
useShadowRoot,
useSlots,
useTemplateRef,
useTransitionState,
vModelCheckbox,
vModelDynamic,
vModelRadio,
vModelSelect,
vModelText,
vShow,
version,
warn,
watch,
watchEffect,
watchPostEffect,
watchSyncEffect,
withAsyncContext,
withCtx,
withDefaults,
withDirectives,
withKeys,
withMemo,
withModifiers,
withScopeId
};
//# sourceMappingURL=vue.js.map

7
docs/.vitepress/cache/deps/vue.js.map vendored Normal file
View File

@ -0,0 +1,7 @@
{
"version": 3,
"sources": [],
"sourcesContent": [],
"mappings": "",
"names": []
}

View File

@ -0,0 +1,20 @@
import { defineConfig } from 'vitepress'
import zh from "./zh";
import en from "./en";
// https://vitepress.dev/reference/site-config
export default defineConfig({
...zh,
locales: {
root: {
label: '简体中文',
lang: 'zh'
},
en: {
label: 'English',
lang: 'en',
link: '/en/',
...en
}
}
})

40
docs/.vitepress/en.ts Normal file
View File

@ -0,0 +1,40 @@
import {defineConfig} from "vitepress";
const en = defineConfig({
title: "MyBot",
description: "MyBot docs",
themeConfig: {
nav: [
{ text: 'Home', link: '/en/' },
{ text: 'Docs', link: '/en/deployment' }
],
sidebar: [
{
text: "For Administrator",
items: [
{ text: "Deployment", link: "/en/deployment" },
{ text: "Configuration", link: "/en/config" }
]
},
{
text: 'For Developer',
items: [
{ text: 'Quick Start', link: '/en/quick-start' },
]
},
{
text: "API Reference",
items: [
{ text: "API Overview", link: '/en/api-list' }
]
}
],
socialLinks: [
{ icon: 'github', link: 'https://github.com/Wzp-2008/MyBot/', ariaLabel: "GitHub" },
{ icon: 'github', link: 'https://wzpmc.cn:3000/wzp/MyBot', ariaLabel: "Gitea" }
],
},
});
export default en;

41
docs/.vitepress/zh.ts Normal file
View File

@ -0,0 +1,41 @@
import {defineConfig} from "vitepress";
const zh = defineConfig({
title: "MyBot",
description: "MyBot文档",
themeConfig: {
// https://vitepress.dev/reference/default-theme-config
nav: [
{ text: '主页', link: '/' },
{ text: '文档', link: '/deployment' }
],
sidebar: [
{
text: "对管理员",
items: [
{ text: "部署MyBot", link: '/deployment' },
{ text: "配置", link: "/config" }
]
},
{
text: '对开发者',
items: [
{ text: '快速开始', link: '/quick-start' },
]
},
{
text: "API参考",
items: [
{ text: "API总览", link: '/api-list' }
]
}
],
socialLinks: [
{ icon: 'github', link: 'https://github.com/Wzp-2008/MyBot/', ariaLabel: "GitHub" },
{ icon: 'github', link: 'https://wzpmc.cn:3000/wzp/MyBot', ariaLabel: "Gitea" }
],
},
});
export default zh;

49
docs/api-list.md Normal file
View File

@ -0,0 +1,49 @@
---
outline: deep
---
# Runtime API Examples
This page demonstrates usage of some of the runtime APIs provided by VitePress.
The main `useData()` API can be used to access site, theme, and page data for the current page. It works in both `.md` and `.vue` files:
```md
<script setup>
import { useData } from 'vitepress'
const { theme, page, frontmatter } = useData()
</script>
## Results
### Theme Data
<pre>{{ theme }}</pre>
### Page Data
<pre>{{ page }}</pre>
### Page Frontmatter
<pre>{{ frontmatter }}</pre>
```
<script setup>
import { useData } from 'vitepress'
const { site, theme, page, frontmatter } = useData()
</script>
## Results
### Theme Data
<pre>{{ theme }}</pre>
### Page Data
<pre>{{ page }}</pre>
### Page Frontmatter
<pre>{{ frontmatter }}</pre>
## More
Check out the documentation for the [full list of runtime APIs](https://vitepress.dev/reference/runtime-api#usedata).

68
docs/config.md Normal file
View File

@ -0,0 +1,68 @@
# 主配置文件 {#main-config}
## 服务器验证 `authorization` {#authorization}
::: warning 实验性功能
此功能可能出现Bug作者的测试环境未找到token配置项若出现BUG请通过[Github Issues](https://github.com/Wzp-2008/MyBot/issues)或[Gitea 工单](https://wzpmc.cn:3000/wzp/MyBot/issues)向作者提交反馈
:::
### enable
是否启动验证
- 类型: `boolean`
- 值:`true` `false`
- 样例:
```yaml
enable: false
```
### token
验证所使用的token
- 类型: `string`
- 不启动验证则留空
- 样例:
```yaml
token: ""
```
---
## 指令执行失败提示 `fallback` {#fallback}
### command
当指令无效时发送的消息
- 类型:`string`
- 样例:
```yaml
command: 无效的指令!
```
### errorUncaught
当指令执行错误时发送的消息
- 类型:`string`
- 样例:
```yaml
errorUncaught: 指令运行时出现错误!
```
---
## 好友相关配置 `friend` {#friend}
### autoAccept
是否自动通过好友申请
- 类型:`boolean`
- 值:`true` `false`
- 样例:
```yaml
autoAccept: true
```
---
## 好友相关配置 `group` {#group}
### autoAccept
是否自动通过群邀请
- 类型:`boolean`
- 值:`true` `false`
- 样例:
```yaml
autoAccept: true
```
---
## ws连接地址 `websocket` {#websocket}
ws连接地址
- 类型:`string`
- 样例:
```yaml
websocket: ws://127.0.0.1:3001
```

47
docs/deployment.md Normal file
View File

@ -0,0 +1,47 @@
# 环境要求
- Java 11(最低) / 17(推荐)
MyBot的可执行文件可以在 [Github Release](https://github.com/Wzp-2008/MyBot/releases/latest) 或 [Gitea Release](https://wzpmc.cn:3000/wzp/MyBot/releases/latest) 下载到
你需要准备一个空文件夹来运行MyBot
::: code-group
```bat [windows (cmd)]
md mybot
cd mybot
```
```powershell [windows (powershell)]
New-Item mybot
cd mybot
```
```bash [linux / macos]
mkdir mybot
cd mybot
```
:::
并将jar文件放置到其中
接下来通过此命令首次启动MyBot
```bash
/path/to/java -jar MyBot-XXXXXX.jar
```
::: tip 注意
将/path/to/java替换为你的java可执行程序路径
:::
启动完成后将会在MyBot文件夹中创建一个config.yml即主配置文件
关于配置文件的修改,请参阅文档中的[配置](/config)一栏
完成配置文件的修改后,再次使用命令
```bash
/path/to/java -jar MyBot-XXXXXX.jar
```
启动MyBot
至此Bot已完成启动~

49
docs/en/api-list.md Normal file
View File

@ -0,0 +1,49 @@
---
outline: deep
---
# Runtime API Examples
This page demonstrates usage of some of the runtime APIs provided by VitePress.
The main `useData()` API can be used to access site, theme, and page data for the current page. It works in both `.md` and `.vue` files:
```md
<script setup>
import { useData } from 'vitepress'
const { theme, page, frontmatter } = useData()
</script>
## Results
### Theme Data
<pre>{{ theme }}</pre>
### Page Data
<pre>{{ page }}</pre>
### Page Frontmatter
<pre>{{ frontmatter }}</pre>
```
<script setup>
import { useData } from 'vitepress'
const { site, theme, page, frontmatter } = useData()
</script>
## Results
### Theme Data
<pre>{{ theme }}</pre>
### Page Data
<pre>{{ page }}</pre>
### Page Frontmatter
<pre>{{ frontmatter }}</pre>
## More
Check out the documentation for the [full list of runtime APIs](https://vitepress.dev/reference/runtime-api#usedata).

68
docs/en/config.md Normal file
View File

@ -0,0 +1,68 @@
# Main Configuration File {#main-config}
## `authorization` {#authorization}
::: warning Experimental
There may be a Bug in this function (the token configuration item is not found in the author's test environment). if there is a BUG, please submit feedback to the author through [Github Issues](https://github.com/Wzp-2008/MyBot/issues) or [Gitea ticket](https://wzpmc.cn:3000/wzp/MyBot/issues)
:::
### enable
should use authorization?
- type `boolean`
- value`true` `false`
- example
```yaml
enable: false
```
### token
The token used on the authorization
- type `string`
- can be empty when not using authorization
- example
```yaml
token: ""
```
---
## `fallback` {#fallback}
### command
when command executing have errors sends message
- type`string`
- example
```yaml
command: Invalid command!
```
### errorUncaught
Message sent when instruction execution fails
- type`string`
- example
```yaml
errorUncaught: Error while command is running!
```
---
## `friend` {#friend}
### autoAccept
Whether to automatically apply through friends
- type`boolean`
- values`true` `false`
- example
```yaml
autoAccept: true
```
---
## `group` {#group}
### autoAccept
Automatically through group invitation
- type`boolean`
- values`true` `false`
- example
```yaml
autoAccept: true
```
---
## `websocket` {#websocket}
ws connection address
- type`string`
- example
```yaml
websocket: ws://127.0.0.1:3001
```

0
docs/en/deployment.md Normal file
View File

25
docs/en/index.md Normal file
View File

@ -0,0 +1,25 @@
---
# https://vitepress.dev/reference/default-theme-home-page
layout: home
hero:
name: "MyBot"
text: "MyBot docs"
tagline: A Java-based OneBot11-compatible robot framework
actions:
- theme: brand
text: Quick Start
link: /deployment
- theme: alt
text: API Reference
link: /api-list
features:
- title: Bukkit Like Plugin Form
details: Minecraft developers can easily get started
- title: API rich
details: compatible with all onebot11 apis and events
- title: Low occupancy
details: The full version only takes up 20M of storage and less than 100M of memory.
---

85
docs/en/quick-start.md Normal file
View File

@ -0,0 +1,85 @@
# Markdown Extension Examples
This page demonstrates some of the built-in markdown extensions provided by VitePress.
## Syntax Highlighting
VitePress provides Syntax Highlighting powered by [Shiki](https://github.com/shikijs/shiki), with additional features like line-highlighting:
**Input**
````md
```js{4}
export default {
data () {
return {
msg: 'Highlighted!'
}
}
}
```
````
**Output**
```js{4}
export default {
data () {
return {
msg: 'Highlighted!'
}
}
}
```
## Custom Containers
**Input**
```md
::: info
This is an info box.
:::
::: tip
This is a tip.
:::
::: warning
This is a warning.
:::
::: danger
This is a dangerous warning.
:::
::: details
This is a details block.
:::
```
**Output**
::: info
This is an info box.
:::
::: tip
This is a tip.
:::
::: warning
This is a warning.
:::
::: danger
This is a dangerous warning.
:::
::: details
This is a details block.
:::
## More
Check out the documentation for the [full list of markdown extensions](https://vitepress.dev/guide/markdown).

25
docs/index.md Normal file
View File

@ -0,0 +1,25 @@
---
# https://vitepress.dev/reference/default-theme-home-page
layout: home
hero:
name: "MyBot"
text: "MyBot 开发文档"
tagline: 一个基于 Java 的 OneBot11 兼容机器人框架
actions:
- theme: brand
text: 快速开始
link: /deployment
- theme: alt
text: API参考
link: /api-list
features:
- title: Bukkit Like插件形式
details: MC开发者可轻松上手
- title: API丰富
details: 兼容所有OneBot11 API\事件
- title: 占用低
details: 完整版仅仅占用20M存储,100M以下内存
---

18
docs/package.json Normal file
View File

@ -0,0 +1,18 @@
{
"name": "mybot-docs",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"docs:dev": "vitepress dev",
"docs:build": "vitepress build",
"docs:preview": "vitepress preview"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"vitepress": "^1.4.0"
}
}

1491
docs/pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

85
docs/quick-start.md Normal file
View File

@ -0,0 +1,85 @@
# 快速开始
This page demonstrates some of the built-in markdown extensions provided by VitePress.
## Syntax Highlighting
VitePress provides Syntax Highlighting powered by [Shiki](https://github.com/shikijs/shiki), with additional features like line-highlighting:
**Input**
````md
```js{4}
export default {
data () {
return {
msg: 'Highlighted!'
}
}
}
```
````
**Output**
```js{4}
export default {
data () {
return {
msg: 'Highlighted!'
}
}
}
```
## Custom Containers
**Input**
```md
::: info
This is an info box.
:::
::: tip
This is a tip.
:::
::: warning
This is a warning.
:::
::: danger
This is a dangerous warning.
:::
::: details
This is a details block.
:::
```
**Output**
::: info
This is an info box.
:::
::: tip
This is a tip.
:::
::: warning
This is a warning.
:::
::: danger
This is a dangerous warning.
:::
::: details
This is a details block.
:::
## More
Check out the documentation for the [full list of markdown extensions](https://vitepress.dev/guide/markdown).

View File

@ -3,7 +3,6 @@ val groupName: String by extra
val projectArtifactId = "mybot-api" val projectArtifactId = "mybot-api"
val projectVersion: String by extra val projectVersion: String by extra
plugins { plugins {
id("java")
id("maven-publish") id("maven-publish")
} }

View File

@ -6,8 +6,6 @@ import com.alibaba.fastjson2.annotation.JSONField;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import java.util.Date;
/** /**
* 群成员信息 * 群成员信息
* *
@ -63,19 +61,19 @@ public class GroupMemberInformation {
*/ */
private String area; private String area;
/** /**
* 加群时间 * 加群时间时间戳
* *
* @since 2024/8/24 19:30 v0.0.6-dev * @since 2024/8/24 19:30 v0.0.6-dev
*/ */
@JSONField(name = "join_time") @JSONField(name = "join_time")
private Date joinTime; private Long joinTime;
/** /**
* 最后发言时间 * 最后发言时间时间戳
* *
* @since 2024/8/24 19:30 v0.0.6-dev * @since 2024/8/24 19:30 v0.0.6-dev
*/ */
@JSONField(name = "last_sent_time") @JSONField(name = "last_sent_time")
private Date lastSentTime; private Long lastSentTime;
/** /**
* 成员等级 * 成员等级
* *
@ -101,12 +99,12 @@ public class GroupMemberInformation {
*/ */
private String title; private String title;
/** /**
* 专属头衔过期时间 * 专属头衔过期时间时间戳
* *
* @since 2024/8/24 19:30 v0.0.6-dev * @since 2024/8/24 19:30 v0.0.6-dev
*/ */
@JSONField(name = "title_expire_time") @JSONField(name = "title_expire_time")
private Date titleExpireTime; private Long titleExpireTime;
/** /**
* 是否允许修改群名片 * 是否允许修改群名片
* *

View File

@ -1,6 +1,7 @@
package cn.wzpmc.events.notice; package cn.wzpmc.events.notice;
import cn.wzpmc.events.notice.admin.GroupAdminChangeEvent; import cn.wzpmc.events.notice.admin.GroupAdminChangeEvent;
import cn.wzpmc.events.notice.essence.EssenceEvent;
import cn.wzpmc.events.notice.file.GroupFileUploadedEvent; import cn.wzpmc.events.notice.file.GroupFileUploadedEvent;
import cn.wzpmc.events.notice.notify.NotifyEvent; import cn.wzpmc.events.notice.notify.NotifyEvent;
import cn.wzpmc.events.notice.recall.GroupMessageRecallEvent; import cn.wzpmc.events.notice.recall.GroupMessageRecallEvent;
@ -70,7 +71,13 @@ public enum NoticeType {
* @see NotifyEvent * @see NotifyEvent
* @since 2024/8/1 下午10:22 v0.0.2-dev * @since 2024/8/1 下午10:22 v0.0.2-dev
*/ */
NOTIFY(NotifyEvent.class); NOTIFY(NotifyEvent.class),
/**
* 精华消息事件
*
* @since 2024/9/16 21:25 v1.0.3
*/
ESSENCE(EssenceEvent.class);
public final Class<? extends NoticeEvent> clazz; public final Class<? extends NoticeEvent> clazz;
NoticeType(Class<? extends NoticeEvent> clazz) { NoticeType(Class<? extends NoticeEvent> clazz) {

View File

@ -0,0 +1,45 @@
package cn.wzpmc.events.notice.essence;
import com.alibaba.fastjson2.annotation.JSONField;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 添加精华消息事件
*
* @author wzp
* @version 1.0.3
* @since 2024/9/16 21:32
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class EssenceAddEvent extends EssenceEvent {
/**
* 群ID
*
* @since 2024/9/16 21:33 v1.0.3
*/
@JSONField(name = "group_id")
private Long groupId;
/**
* 设置人ID
*
* @since 2024/9/16 21:33 v1.0.3
*/
@JSONField(name = "user_id")
private Long userId;
/**
* 消息ID
*
* @since 2024/9/16 21:33 v1.0.3
*/
@JSONField(name = "message_id")
private Long messageId;
/**
* 消息发送者ID
*
* @since 2024/9/16 21:33 v1.0.3
*/
@JSONField(name = "sender_id")
private Long senderId;
}

View File

@ -0,0 +1,25 @@
package cn.wzpmc.events.notice.essence;
import cn.wzpmc.events.notice.NoticeEvent;
import com.alibaba.fastjson2.annotation.JSONField;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 精华消息事件
*
* @author wzp
* @version 1.0.3
* @since 2024/9/16 21:24
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class EssenceEvent extends NoticeEvent {
/**
* 群精华消息子类型
*
* @since 2024/8/1 下午11:26 v0.0.2-dev
*/
@JSONField(name = "sub_type")
private EssenceSubType subType;
}

View File

@ -0,0 +1,22 @@
package cn.wzpmc.events.notice.essence;
/**
* 精华消息子事件
*
* @author wzp
* @version 1.0.3
* @since 2024/9/16 21:31
*/
public enum EssenceSubType {
/**
* 添加精华消息事件
*
* @since 2024/9/16 21:35 v1.0.3
*/
ADD(EssenceAddEvent.class);
public final Class<? extends EssenceEvent> clazz;
EssenceSubType(Class<? extends EssenceEvent> clazz) {
this.clazz = clazz;
}
}

View File

@ -21,6 +21,7 @@ public interface JsonMessagePart {
* @author wzp * @author wzp
* @since 2024/7/31 上午2:40 v0.0.1-dev * @since 2024/7/31 上午2:40 v0.0.1-dev
*/ */
@JSONField(serialize = false, deserialize = false)
PartType getPartType(); PartType getPartType();
@JSONField(name = "type") @JSONField(name = "type")

View File

@ -140,7 +140,13 @@ public enum PartType {
* *
* @since 2024/8/25 15:20 v1.0.0 * @since 2024/8/25 15:20 v1.0.0
*/ */
MARKDOWN(MarkdownMessage.class); MARKDOWN(MarkdownMessage.class),
/**
* 未知消息类型
*
* @since 2024/11/17 17:23 v1.0.5
*/
UNKNOWN(UnknownPart.class);
public final Class<? extends JsonMessagePart> clazz; public final Class<? extends JsonMessagePart> clazz;
PartType(Class<? extends JsonMessagePart> clazz) { PartType(Class<? extends JsonMessagePart> clazz) {

View File

@ -0,0 +1,47 @@
package cn.wzpmc.message.json.parts;
import cn.wzpmc.message.json.JsonMessagePart;
import com.alibaba.fastjson2.JSONObject;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 未知消息类型
*
* @author wzp
* @version 1.0.5
* @since 2024/11/17 17:22
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UnknownPart implements JsonMessagePart {
/**
* 类型文本
*
* @since 2024/11/17 17:32 v1.0.5
*/
private String type;
/**
* 消息数据
*
* @since 2024/11/17 17:33 v1.0.5
*/
private JSONObject data;
@Override
public PartType getPartType() {
return PartType.UNKNOWN;
}
@Override
public String getStringPartType() {
return type;
}
@Override
public JSONObject getData() {
return data;
}
}

View File

@ -1,6 +1,7 @@
package cn.wzpmc.plugins; package cn.wzpmc.plugins;
import cn.wzpmc.user.IBot; import cn.wzpmc.user.IBot;
import com.alibaba.fastjson2.JSONObject;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import java.io.File; import java.io.File;
@ -115,4 +116,19 @@ public interface BasePlugin {
* @since 2024/8/16 13:16 v0.0.5-dev * @since 2024/8/16 13:16 v0.0.5-dev
*/ */
void saveDefaultConfig(); void saveDefaultConfig();
/**
* 重载配置文件
* @author wzp
* @since 2024/10/10 09:36 v1.0.3
*/
void reloadConfig();
/**
* 获取配置文件内容
* @author wzp
* @since 2024/10/10 09:37 v1.0.3
* @return 配置文件内容
*/
JSONObject getConfig();
} }

View File

@ -1,16 +1,15 @@
package cn.wzpmc.plugins; package cn.wzpmc.plugins;
import cn.wzpmc.user.IBot; import cn.wzpmc.user.IBot;
import com.alibaba.fastjson2.JSONObject;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.yaml.snakeyaml.Yaml;
import java.io.File; import java.io.*;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
/** /**
* Java插件基类 * Java插件基类
@ -29,6 +28,11 @@ public abstract class JavaPlugin implements BasePlugin {
* @since 2024/8/23 21:42 v0.0.5-dev * @since 2024/8/23 21:42 v0.0.5-dev
*/ */
private Logger logger; private Logger logger;
/**
* 配置文件缓存
* @since 2024/10/10 09:35 v1.0.3
*/
private JSONObject config;
@Override @Override
public IPluginClassLoader getClassLoader() { public IPluginClassLoader getClassLoader() {
@ -89,12 +93,36 @@ public abstract class JavaPlugin implements BasePlugin {
@Override @Override
public void saveDefaultConfig() { public void saveDefaultConfig() {
try (InputStream resourceAsStream = this.getResourceAsStream("config.yml")) { try (InputStream resourceAsStream = this.getResourceAsStream("config.yml")) {
if (resourceAsStream == null){
log.error("config.yml no found");
return;
}
File defaultConfigFile = this.getDefaultConfigFile(); File defaultConfigFile = this.getDefaultConfigFile();
if (!defaultConfigFile.exists()) {
try (FileOutputStream fileOutputStream = new FileOutputStream(defaultConfigFile)) { try (FileOutputStream fileOutputStream = new FileOutputStream(defaultConfigFile)) {
resourceAsStream.transferTo(fileOutputStream); resourceAsStream.transferTo(fileOutputStream);
} }
}
} catch (IOException e) { } catch (IOException e) {
log.error(e); log.error(e);
} }
} }
public void reloadConfig() {
File file = new File(this.getDataFolder(), "config.yml");
if (!file.exists()) {
saveDefaultConfig();
}
try(FileInputStream fis = new FileInputStream(file)) {
this.config = new Yaml().loadAs(fis, JSONObject.class);
} catch (IOException e) {
this.logger.error("加载配置文件时出错!");
this.logger.throwing(e);
}
}
public JSONObject getConfig() {
if (this.config == null) {
reloadConfig();
}
return this.config;
}
} }

View File

@ -8,12 +8,20 @@ package cn.wzpmc.plugins.configuration;
* @since 2024/7/31 上午3:42 * @since 2024/7/31 上午3:42
*/ */
public interface IConfiguration { public interface IConfiguration {
/** /**
* @return WebSocket连接URL
* @author wzp * @author wzp
* @since 2024/7/31 上午3:48 v0.0.1-dev * @since 2025/3/26 17:29 v1.0.7
* @return 网络相关配置
*/ */
String getWebsocket(); INetworkConfiguration getNetwork();
/**
*
* @author wzp
* @since 2025/2/4 13:44 v1.0.5
* @return 命令前缀
*/
String getCommandPrefix();
/** /**
* @return 通信验证 * @return 通信验证

View File

@ -0,0 +1,38 @@
package cn.wzpmc.plugins.configuration;
/**
* @author wzp
* @since 2025/3/26 17:26
* @version 1.0.7
*/
public interface INetworkConfiguration {
/**
* @return WebSocket连接URL
* @author wzp
* @since 2025/3/26 17:26 v1.0.7
*/
String getWebsocket();
/**
* @author wzp
* @since 2025/3/26 17:27 v1.0.7
* @return 是否启用连接重试
*/
Boolean isRetry();
/**
* @author wzp
* @since 2025/3/26 17:27 v1.0.7
* @return 重试最大次数-1为无限
*/
Integer getMaxRetryCount();
/**
* @author wzp
* @since 2025/3/26 17:28 v1.0.7
* @return 获取重试间隔单位毫秒
*/
Long getRetryInterval();
}

View File

@ -3,6 +3,7 @@ package cn.wzpmc.utils;
import cn.wzpmc.message.json.JsonMessagePart; import cn.wzpmc.message.json.JsonMessagePart;
import cn.wzpmc.message.json.parts.At; import cn.wzpmc.message.json.parts.At;
import cn.wzpmc.message.json.parts.PartType; import cn.wzpmc.message.json.parts.PartType;
import cn.wzpmc.message.json.parts.UnknownPart;
import cn.wzpmc.message.json.parts.music.MusicType; import cn.wzpmc.message.json.parts.music.MusicType;
import cn.wzpmc.message.json.parts.node.CustomNode; import cn.wzpmc.message.json.parts.node.CustomNode;
import cn.wzpmc.message.json.parts.node.SingleNode; import cn.wzpmc.message.json.parts.node.SingleNode;
@ -111,9 +112,18 @@ public class CqCodeUtils {
* @since 2024/8/26 14:40 v1.0.0 * @since 2024/8/26 14:40 v1.0.0
*/ */
public static JsonMessagePart parsePart(JSONObject jsonObject) throws InvocationTargetException, InstantiationException, IllegalAccessException, NoSuchMethodException { public static JsonMessagePart parsePart(JSONObject jsonObject) throws InvocationTargetException, InstantiationException, IllegalAccessException, NoSuchMethodException {
PartType type = jsonObject.getObject("type", PartType.class); PartType type = PartType.UNKNOWN;
PartType resolvedType = jsonObject.getObject("type", PartType.class);
if (resolvedType != null) {
type = resolvedType;
}
Class<? extends JsonMessagePart> clazz = type.clazz; Class<? extends JsonMessagePart> clazz = type.clazz;
JSONObject dataObject = jsonObject.getJSONObject("data"); JSONObject dataObject = jsonObject.getJSONObject("data");
if (type.equals(PartType.UNKNOWN)) {
String stringType = jsonObject.getString("type");
log.warn("发现无法解析的json消息数据数据类型{},数据内容:{}", stringType, dataObject);
return new UnknownPart(stringType, dataObject);
}
if (type.equals(PartType.AT)) { if (type.equals(PartType.AT)) {
String string = dataObject.getString("qq"); String string = dataObject.getString("qq");
if (string.equalsIgnoreCase("all")) { if (string.equalsIgnoreCase("all")) {

View File

@ -18,6 +18,7 @@ import cn.wzpmc.utils.JsonUtils;
import cn.wzpmc.utils.ReflectionUtils; import cn.wzpmc.utils.ReflectionUtils;
import cn.wzpmc.utils.TemplateFileUtils; import cn.wzpmc.utils.TemplateFileUtils;
import cn.wzpmc.utils.YamlUtils; import cn.wzpmc.utils.YamlUtils;
import com.alibaba.fastjson2.JSONObject;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
@ -52,6 +53,7 @@ public class Main {
} }
log.debug("读取配置文件 {}", configurationFile.getAbsolutePath()); log.debug("读取配置文件 {}", configurationFile.getAbsolutePath());
Configuration configuration = YamlUtils.readYamlFile(configurationFile, Configuration.class); Configuration configuration = YamlUtils.readYamlFile(configurationFile, Configuration.class);
JSONObject fullConfiguration = YamlUtils.readYamlFile(configurationFile, JSONObject.class);
Configuration defaultConfiguration = TemplateFileUtils.readDefaultConfig(classLoader, DEFAULT_CONFIGURATION_FILE_PATH, Configuration.class); Configuration defaultConfiguration = TemplateFileUtils.readDefaultConfig(classLoader, DEFAULT_CONFIGURATION_FILE_PATH, Configuration.class);
// 配置文件自动更新 start // 配置文件自动更新 start
boolean isChanged = false; boolean isChanged = false;
@ -73,11 +75,24 @@ public class Main {
isChanged = true; isChanged = true;
} }
// end // end
// 1.0.7 配置文件自动更新
if (configuration.getCommandPrefix() == null) {
configuration.setCommandPrefix(defaultConfiguration.getCommandPrefix());
isChanged = true;
}
if (configuration.getNetwork() == null) {
configuration.setNetwork(defaultConfiguration.getNetwork());
configuration.getNetwork().setWebsocket(fullConfiguration.getString("websocket"));
isChanged = true;
}
// end
if (isChanged) { if (isChanged) {
log.warn("已自动升级配置文件请检查config.yml是否有错误的地方有则请修改"); log.warn("已自动升级配置文件请检查config.yml是否有错误的地方有则请修改");
YamlUtils.writeYamlFile(configurationFile, configuration); YamlUtils.writeYamlFile(configurationFile, configuration);
} }
// 配置文件自动更新end // 配置文件自动更新end
return configuration; return configuration;
} }
@ -88,7 +103,7 @@ public class Main {
public static URI getUriFromConfiguration(Configuration configuration) { public static URI getUriFromConfiguration(Configuration configuration) {
URI uri; URI uri;
try { try {
uri = new URI(configuration.getWebsocket()); uri = new URI(configuration.getNetwork().getWebsocket());
} catch (URISyntaxException e) { } catch (URISyntaxException e) {
return null; return null;
} }
@ -127,8 +142,8 @@ public class Main {
} }
public static WebSocketConnectionHandler createConnection(MyBot myBot, URI uri) { public static WebSocketConnectionHandler createConnection(MyBot myBot, URI uri) {
WebSocketConnectionHandler webSocketConnectionHandler = new WebSocketConnectionHandler(myBot); WebSocketConnectionHandler webSocketConnectionHandler = new WebSocketConnectionHandler(myBot, uri);
webSocketConnectionHandler.connect(uri); webSocketConnectionHandler.connect();
return webSocketConnectionHandler; return webSocketConnectionHandler;
} }

View File

@ -25,10 +25,12 @@ import java.util.concurrent.ConcurrentHashMap;
*/ */
public class HelpCommand implements BrigadierCommand { public class HelpCommand implements BrigadierCommand {
private final CommandManager commandManager; private final CommandManager commandManager;
private final String commandPrefix;
public HelpCommand() { public HelpCommand() {
IBot instance = MyBot.getInstance(); IBot instance = MyBot.getInstance();
this.commandManager = (CommandManager) instance.getCommandManager(); this.commandManager = (CommandManager) instance.getCommandManager();
this.commandPrefix = instance.getConfiguration().getCommandPrefix();
} }
private static void handlerNode(Collection<CommandNode<CommandSender>> node, int tabCount, StringBuilder builder) { private static void handlerNode(Collection<CommandNode<CommandSender>> node, int tabCount, StringBuilder builder) {
@ -54,7 +56,7 @@ public class HelpCommand implements BrigadierCommand {
CommandSender source = e.getSource(); CommandSender source = e.getSource();
for (CommandNode<CommandSender> child : children) { for (CommandNode<CommandSender> child : children) {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append('/'); builder.append(commandPrefix);
builder.append(child.getUsageText()); builder.append(child.getUsageText());
builder.append('\n'); builder.append('\n');
handlerNode(child.getChildren(), 1, builder); handlerNode(child.getChildren(), 1, builder);
@ -63,7 +65,7 @@ public class HelpCommand implements BrigadierCommand {
} }
ConcurrentHashMap<String, RawCommand> rawCommands = this.commandManager.getRawCommands(); ConcurrentHashMap<String, RawCommand> rawCommands = this.commandManager.getRawCommands();
for (Map.Entry<String, RawCommand> stringRawCommandEntry : rawCommands.entrySet()) { for (Map.Entry<String, RawCommand> stringRawCommandEntry : rawCommands.entrySet()) {
source.sendMessage(StringMessage.text("/" + stringRawCommandEntry.getKey())); source.sendMessage(StringMessage.text(commandPrefix + stringRawCommandEntry.getKey()));
} }
return 0; return 0;
}). }).
@ -78,7 +80,7 @@ public class HelpCommand implements BrigadierCommand {
continue; continue;
} }
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append('/'); builder.append(commandPrefix);
builder.append(child.getUsageText()); builder.append(child.getUsageText());
builder.append('\n'); builder.append('\n');
handlerNode(child.getChildren(), 1, builder); handlerNode(child.getChildren(), 1, builder);
@ -87,7 +89,7 @@ public class HelpCommand implements BrigadierCommand {
} }
ConcurrentHashMap<String, RawCommand> rawCommands = this.commandManager.getRawCommands(); ConcurrentHashMap<String, RawCommand> rawCommands = this.commandManager.getRawCommands();
for (Map.Entry<String, RawCommand> stringRawCommandEntry : rawCommands.entrySet()) { for (Map.Entry<String, RawCommand> stringRawCommandEntry : rawCommands.entrySet()) {
source.sendMessage(StringMessage.text("/" + stringRawCommandEntry.getKey())); source.sendMessage(StringMessage.text(commandPrefix + stringRawCommandEntry.getKey()));
} }
return 0; return 0;
}) })

View File

@ -3,6 +3,7 @@ package cn.wzpmc.builtin.event;
import cn.wzpmc.api.IMainApi; import cn.wzpmc.api.IMainApi;
import cn.wzpmc.api.actions.message.set.SetGroupAddRequestAction; import cn.wzpmc.api.actions.message.set.SetGroupAddRequestAction;
import cn.wzpmc.events.request.group.GroupJoinRequestEvent; import cn.wzpmc.events.request.group.GroupJoinRequestEvent;
import cn.wzpmc.events.request.group.GroupJoinRequestEventSubType;
import cn.wzpmc.plugins.event.EventHandler; import cn.wzpmc.plugins.event.EventHandler;
import cn.wzpmc.user.IBot; import cn.wzpmc.user.IBot;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
@ -20,7 +21,10 @@ public class AddGroupEventHandler {
public void onUserInvite(GroupJoinRequestEvent event) { public void onUserInvite(GroupJoinRequestEvent event) {
IBot instance = IBot.getInstance(); IBot instance = IBot.getInstance();
IMainApi mainApi = instance.getMainApi(); IMainApi mainApi = instance.getMainApi();
mainApi.doApiCallSafe(new SetGroupAddRequestAction(event.getFlag(), event.getSubType())); GroupJoinRequestEventSubType subType = event.getSubType();
if (subType.equals(GroupJoinRequestEventSubType.INVITE)) {
mainApi.doApiCallSafe(new SetGroupAddRequestAction(event.getFlag(), GroupJoinRequestEventSubType.INVITE));
log.info("用户{}邀请你加入群{},已同意", event.getUserId(), event.getGroupId()); log.info("用户{}邀请你加入群{},已同意", event.getUserId(), event.getGroupId());
} }
} }
}

View File

@ -26,12 +26,14 @@ public class CommandEventHandler {
public void onGroupMessage(GroupMessageEvent event) { public void onGroupMessage(GroupMessageEvent event) {
GroupCommandSender groupCommandSender = GroupCommandSender.of(event); GroupCommandSender groupCommandSender = GroupCommandSender.of(event);
IBot instance = MyBot.getInstance(); IBot instance = MyBot.getInstance();
String commandPrefix = instance.getConfiguration().getCommandPrefix();
Long id = instance.getId(); Long id = instance.getId();
String message = event.getRawMessage().getMessage(); String message = event.getRawMessage().getMessage();
Pattern compile = Pattern.compile("\\[CQ:at,qq=" + id + ".*?]\\s*?/.*"); String quotedPrefix = Pattern.quote(commandPrefix);
Pattern compile = Pattern.compile("\\[CQ:at,qq=" + id + ".*?]\\s*?" + quotedPrefix + ".*");
if (compile.asMatchPredicate().test(message)) { if (compile.asMatchPredicate().test(message)) {
CommandManager commandManager = (CommandManager) instance.getCommandManager(); CommandManager commandManager = (CommandManager) instance.getCommandManager();
String commandRaw = message.replaceFirst("\\[CQ:at,qq=[0-9]{10}.*?]\\s*?/", ""); String commandRaw = message.replaceFirst("\\[CQ:at,qq=[0-9]{10}.*?]\\s*?" + quotedPrefix, "");
log.info("群{}中的用户{}使用了指令{}", groupCommandSender.getGroupId(), groupCommandSender.getId(), commandRaw); log.info("群{}中的用户{}使用了指令{}", groupCommandSender.getGroupId(), groupCommandSender.getId(), commandRaw);
commandManager.execute(groupCommandSender, commandRaw); commandManager.execute(groupCommandSender, commandRaw);
} }
@ -43,9 +45,10 @@ public class CommandEventHandler {
IBot instance = MyBot.getInstance(); IBot instance = MyBot.getInstance();
StringMessage rawMessage = event.getRawMessage(); StringMessage rawMessage = event.getRawMessage();
String message = rawMessage.getMessage(); String message = rawMessage.getMessage();
if (message.startsWith("/")) { String commandPrefix = instance.getConfiguration().getCommandPrefix();
if (message.startsWith(commandPrefix)) {
CommandManager commandManager = (CommandManager) instance.getCommandManager(); CommandManager commandManager = (CommandManager) instance.getCommandManager();
String commandRaw = message.replaceFirst("/", ""); String commandRaw = message.replaceFirst(commandPrefix, "");
log.info("用户{}使用了指令{}", sender.getId(), commandRaw); log.info("用户{}使用了指令{}", sender.getId(), commandRaw);
commandManager.execute(sender, commandRaw); commandManager.execute(sender, commandRaw);
} }

View File

@ -12,12 +12,19 @@ import lombok.Data;
*/ */
@Data @Data
public class Configuration implements IConfiguration { public class Configuration implements IConfiguration {
/** /**
* WebSocket连接URL * 网络相关配置
* * @since 2025/3/26 17:32 v1.0.7
* @since 2024/7/30 下午11:48 v0.0.1-dev
*/ */
private String websocket; private NetworkConfiguration network;
/**
* 命令前缀
* @since 2025/2/4 13:45 v1.0.5
*/
private String commandPrefix;
/** /**
* 通信验证 * 通信验证
* *

View File

@ -0,0 +1,38 @@
package cn.wzpmc.configuration;
import cn.wzpmc.plugins.configuration.INetworkConfiguration;
import lombok.Data;
/**
* @author wzp
* @since 2025/3/26 17:29
* @version 1.0.7
*/
@Data
public class NetworkConfiguration implements INetworkConfiguration {
/**
* WebSocket连接URL
* @since 2025/3/26 17:31 v1.0.7
*/
private String websocket;
/**
* 是否启用连接重试
* @since 2025/3/26 17:31 v1.0.7
*/
private Boolean retry;
/**
* 重试最大次数-1为无限
* @since 2025/3/26 17:31 v1.0.7
*/
private Integer maxRetryCount;
/**
* 获取重试间隔单位毫秒
* @since 2025/3/26 17:31 v1.0.7
*/
private Long retryInterval;
@Override
public Boolean isRetry() {
return this.retry;
}
}

View File

@ -1,8 +1,10 @@
package cn.wzpmc.console; package cn.wzpmc.console;
import cn.wzpmc.entities.api.ApiResponseRequired;
import cn.wzpmc.entities.user.bot.MyBot; import cn.wzpmc.entities.user.bot.MyBot;
import cn.wzpmc.network.WebSocketConnectionHandler; import cn.wzpmc.network.WebSocketConnectionHandler;
import cn.wzpmc.plugins.CommandManager; import cn.wzpmc.plugins.CommandManager;
import cn.wzpmc.utils.json.action.ActionReader;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
@ -47,12 +49,16 @@ public class MyBotConsole extends SimpleTerminalConsole {
@Override @Override
public void shutdown() { public void shutdown() {
this.webSocketConnectionHandler.kill(); this.webSocketConnectionHandler.kill();
for (ApiResponseRequired<?, ?> value : ActionReader.tasks.values()) {
value.getFuture().complete(null);
}
running = false; running = false;
} }
@Override @Override
public void start() { public void start() {
this.bot.setConsole(this); this.bot.setConsole(this);
if (this.bot.isShutdown()) return;
super.start(); super.start();
} }
} }

View File

@ -50,6 +50,8 @@ public class MyBot extends IBot {
private final Configuration configuration; private final Configuration configuration;
private final CommandManager commandManager = new CommandManager(this); private final CommandManager commandManager = new CommandManager(this);
private final PluginManager pluginManager = new PluginManager(); private final PluginManager pluginManager = new PluginManager();
@Setter
private boolean shutdown = false;
private final IncreasbleHashMap<Class<? extends Event>, EventHandlerMethod> events = new IncreasbleHashMap<>(); private final IncreasbleHashMap<Class<? extends Event>, EventHandlerMethod> events = new IncreasbleHashMap<>();
@Getter @Getter
private final Ops ops; private final Ops ops;

View File

@ -37,7 +37,6 @@ public class HandshakePacketHandler extends SimpleChannelInboundHandler<FullHttp
handshaker.finishHandshake(channelHandlerContext.channel(), fullHttpResponse); handshaker.finishHandshake(channelHandlerContext.channel(), fullHttpResponse);
this.handshakeFuture.complete(true); this.handshakeFuture.complete(true);
log.debug("握手成功"); log.debug("握手成功");
log.info("连接服务器成功!");
} }
} }
} }

View File

@ -32,6 +32,8 @@ import java.util.concurrent.Executors;
public class PacketHandler extends SimpleChannelInboundHandler<TextWebSocketFrame> { public class PacketHandler extends SimpleChannelInboundHandler<TextWebSocketFrame> {
private final IBot bot; private final IBot bot;
private final ExecutorService threadPool = Executors.newFixedThreadPool(4); private final ExecutorService threadPool = Executors.newFixedThreadPool(4);
private final Runnable retryFunction;
@Override @Override
protected void channelRead0(ChannelHandlerContext channelHandlerContext, TextWebSocketFrame webSocketFrame) { protected void channelRead0(ChannelHandlerContext channelHandlerContext, TextWebSocketFrame webSocketFrame) {
@ -105,4 +107,10 @@ public class PacketHandler extends SimpleChannelInboundHandler<TextWebSocketFram
public <REQUEST, RESPONSE> void registerResponse(UUID echo, CompletableFuture<ActionResponse<RESPONSE>> responsePromise, Action<REQUEST, RESPONSE> request) { public <REQUEST, RESPONSE> void registerResponse(UUID echo, CompletableFuture<ActionResponse<RESPONSE>> responsePromise, Action<REQUEST, RESPONSE> request) {
ActionReader.tasks.put(echo, new ApiResponseRequired<>(responsePromise, request)); ActionReader.tasks.put(echo, new ApiResponseRequired<>(responsePromise, request));
} }
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
log.info("与服务器断开连接!");
retryFunction.run();
}
} }

View File

@ -2,7 +2,11 @@ package cn.wzpmc.network;
import cn.wzpmc.api.Action; import cn.wzpmc.api.Action;
import cn.wzpmc.api.ActionResponse; import cn.wzpmc.api.ActionResponse;
import cn.wzpmc.user.IBot; import cn.wzpmc.console.MyBotConsole;
import cn.wzpmc.entities.api.ApiResponseRequired;
import cn.wzpmc.entities.user.bot.MyBot;
import cn.wzpmc.plugins.configuration.INetworkConfiguration;
import cn.wzpmc.utils.json.action.ActionReader;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.Bootstrap;
import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFuture;
@ -32,26 +36,70 @@ import java.util.concurrent.ExecutionException;
@RequiredArgsConstructor @RequiredArgsConstructor
public class WebSocketConnectionHandler { public class WebSocketConnectionHandler {
private final EventLoopGroup eventLoopGroup = new NioEventLoopGroup(); private final EventLoopGroup eventLoopGroup = new NioEventLoopGroup();
private final IBot bot; private final MyBot bot;
/**
* websocket连接地址
* @since 2025/3/26 17:56 v1.0.7
*/
private final URI websocket;
private ChannelFuture channelFuture; private ChannelFuture channelFuture;
private PacketHandler packetHandler; private PacketHandler packetHandler;
private HandshakePacketHandler handshakePacketHandler; private HandshakePacketHandler handshakePacketHandler;
private int currentRetryCount = 0;
private void tryReconnect() {
INetworkConfiguration network = bot.getConfiguration().getNetwork();
if (!network.isRetry()) {
this.quit();
return;
}
Integer maxRetryCount = network.getMaxRetryCount();
if (maxRetryCount != 0 && currentRetryCount >= maxRetryCount) {
this.quit();
return;
}
this.currentRetryCount++;
log.info("尝试重连第{}次", currentRetryCount);
this.connect();
}
private void quit() {
for (ApiResponseRequired<?, ?> value : ActionReader.tasks.values()) {
value.getFuture().obtrudeException(new InterruptedException());
}
this.handshakePacketHandler.getHandshakeFuture().obtrudeException(new InterruptedException());
MyBotConsole console = bot.getConsole();
bot.setShutdown(true);
if (console == null) {
this.eventLoopGroup.shutdownGracefully();
return;
}
console.shutdown();
}
/** /**
* 建立连接 * 建立连接
*
* @param websocket websocket连接地址
* @author wzp * @author wzp
* @since 2024/7/30 下午11:55 v0.0.1-dev * @since 2024/7/30 下午11:55 v0.0.1-dev
*/ */
public void connect(URI websocket) { public void connect() {
log.info("正在连接websocket"); log.info("正在连接websocket");
Bootstrap bootstrap = new Bootstrap(); Bootstrap bootstrap = new Bootstrap();
WebSocketClientHandshaker clientHandshaker = WebSocketClientHandshakerFactory.newHandshaker(websocket, WebSocketVersion.V13, null, false, new DefaultHttpHeaders()); WebSocketClientHandshaker clientHandshaker = WebSocketClientHandshakerFactory.newHandshaker(websocket, WebSocketVersion.V13, null, false, new DefaultHttpHeaders(), 65536 * 100);
this.handshakePacketHandler = new HandshakePacketHandler(clientHandshaker); this.handshakePacketHandler = new HandshakePacketHandler(clientHandshaker);
this.packetHandler = new PacketHandler(this.bot); this.packetHandler = new PacketHandler(this.bot, this::tryReconnect);
bootstrap.group(eventLoopGroup).channel(NioSocketChannel.class).handler(new WebSocketChannelInitializer(this.packetHandler, this.handshakePacketHandler)); bootstrap.group(eventLoopGroup).channel(NioSocketChannel.class).handler(new WebSocketChannelInitializer(this.packetHandler, this.handshakePacketHandler));
this.channelFuture = bootstrap.connect(websocket.getHost(), websocket.getPort()); this.channelFuture = bootstrap.connect(websocket.getHost(), websocket.getPort());
this.channelFuture.addListener(future -> {
if (!future.isSuccess()) {
log.info("连接失败!");
this.tryReconnect();
} else {
log.info("连接成功!");
this.currentRetryCount = 0;
}
});
} }
/** /**
@ -81,6 +129,7 @@ public class WebSocketConnectionHandler {
this.handshakePacketHandler.getHandshakeFuture().get(); this.handshakePacketHandler.getHandshakeFuture().get();
} catch (ExecutionException e) { } catch (ExecutionException e) {
log.error(e); log.error(e);
return null;
} }
CompletableFuture<ActionResponse<RESPONSE>> responsePromise = new CompletableFuture<>(); CompletableFuture<ActionResponse<RESPONSE>> responsePromise = new CompletableFuture<>();
packetHandler.registerResponse(request.getEcho(), responsePromise, request); packetHandler.registerResponse(request.getEcho(), responsePromise, request);

View File

@ -7,10 +7,12 @@ import cn.wzpmc.events.Event;
import cn.wzpmc.events.message.MessageEvent; import cn.wzpmc.events.message.MessageEvent;
import cn.wzpmc.events.meta.MetaEvent; import cn.wzpmc.events.meta.MetaEvent;
import cn.wzpmc.events.notice.NoticeEvent; import cn.wzpmc.events.notice.NoticeEvent;
import cn.wzpmc.events.notice.essence.EssenceEvent;
import cn.wzpmc.events.notice.notify.NotifyEvent; import cn.wzpmc.events.notice.notify.NotifyEvent;
import cn.wzpmc.events.request.RequestEvent; import cn.wzpmc.events.request.RequestEvent;
import cn.wzpmc.message.StringMessage; import cn.wzpmc.message.StringMessage;
import cn.wzpmc.message.json.JsonMessage; import cn.wzpmc.message.json.JsonMessage;
import cn.wzpmc.message.json.JsonMessagePart;
import cn.wzpmc.user.Friend; import cn.wzpmc.user.Friend;
import cn.wzpmc.user.IBot; import cn.wzpmc.user.IBot;
import cn.wzpmc.user.IUser; import cn.wzpmc.user.IUser;
@ -19,10 +21,7 @@ import cn.wzpmc.utils.json.action.ActionReader;
import cn.wzpmc.utils.json.action.ActionWriter; import cn.wzpmc.utils.json.action.ActionWriter;
import cn.wzpmc.utils.json.event.*; import cn.wzpmc.utils.json.event.*;
import cn.wzpmc.utils.json.honor.HonorWriter; import cn.wzpmc.utils.json.honor.HonorWriter;
import cn.wzpmc.utils.json.message.JsonMessageReader; import cn.wzpmc.utils.json.message.*;
import cn.wzpmc.utils.json.message.JsonMessageWriter;
import cn.wzpmc.utils.json.message.StringMessageReader;
import cn.wzpmc.utils.json.message.StringMessageWriter;
import cn.wzpmc.utils.json.user.FriendUserReader; import cn.wzpmc.utils.json.user.FriendUserReader;
import cn.wzpmc.utils.json.user.GroupUserReader; import cn.wzpmc.utils.json.user.GroupUserReader;
import cn.wzpmc.utils.json.user.IBotReader; import cn.wzpmc.utils.json.user.IBotReader;
@ -48,6 +47,7 @@ public class JsonUtils {
JSON.register(Actions.class, new ActionWriter()); JSON.register(Actions.class, new ActionWriter());
JSON.register(HonorType.class, new HonorWriter()); JSON.register(HonorType.class, new HonorWriter());
JSON.register(StringMessage.class, new StringMessageWriter()); JSON.register(StringMessage.class, new StringMessageWriter());
JSON.register(JsonMessagePart.class, new JsonMessagePartWriter());
} }
/** /**
@ -70,6 +70,7 @@ public class JsonUtils {
JSON.register(IBot.class, new IBotReader()); JSON.register(IBot.class, new IBotReader());
JSON.register(Friend.class, new FriendUserReader()); JSON.register(Friend.class, new FriendUserReader());
JSON.register(GroupUser.class, new GroupUserReader()); JSON.register(GroupUser.class, new GroupUserReader());
JSON.register(EssenceEvent.class, new EssenceEventReader());
} }
} }

View File

@ -1,6 +1,7 @@
package cn.wzpmc.utils; package cn.wzpmc.utils;
import cn.wzpmc.configuration.Configuration; import cn.wzpmc.configuration.Configuration;
import com.alibaba.fastjson2.JSONObject;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.Yaml;
@ -30,7 +31,8 @@ public class YamlUtils {
*/ */
public static <T> T readYamlStream(InputStream is, Class<T> clazz) { public static <T> T readYamlStream(InputStream is, Class<T> clazz) {
Yaml yaml = new Yaml(); Yaml yaml = new Yaml();
return yaml.loadAs(is, clazz); JSONObject json = yaml.loadAs(is, JSONObject.class);
return json.to(clazz);
} }
/** /**

View File

@ -0,0 +1,27 @@
package cn.wzpmc.utils.json.event;
import cn.wzpmc.events.notice.essence.EssenceEvent;
import cn.wzpmc.events.notice.essence.EssenceSubType;
import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.JSONReader;
import com.alibaba.fastjson2.reader.ObjectReader;
import java.lang.reflect.Type;
/**
* @author wzp
* @version 1.0.3
* @since 2024/9/16 21:36
*/
public class EssenceEventReader implements ObjectReader<EssenceEvent> {
@Override
public EssenceEvent readObject(JSONReader jsonReader, Type type, Object o, long l) {
JSONReader.SavePoint mark = jsonReader.mark();
JSONObject jsonObject = jsonReader.readJSONObject();
EssenceSubType postType = EssenceSubType.valueOf(jsonObject.getString("sub_type").toUpperCase());
jsonReader.reset(mark);
EssenceEvent event = jsonReader.read(postType.clazz);
jsonReader.close();
return event;
}
}

View File

@ -0,0 +1,25 @@
package cn.wzpmc.utils.json.message;
import cn.wzpmc.message.json.JsonMessagePart;
import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.JSONWriter;
import com.alibaba.fastjson2.writer.ObjectWriter;
import java.lang.reflect.Type;
/**
* @author wzp
* @since 2025/2/1 04:19
* @version 1.0.5
**/
public class JsonMessagePartWriter implements ObjectWriter<JsonMessagePart> {
@Override
public void write(JSONWriter jsonWriter, Object object, Object fieldName, Type fieldType, long features) {
if (object instanceof JsonMessagePart) {
System.out.println(object);
JSONObject from = JSONObject.from(object);
from.put("type", ((JsonMessagePart) object).getStringPartType());
jsonWriter.write(from);
}
}
}

View File

@ -34,7 +34,7 @@ public class JsonMessageWriter implements ObjectWriter<JsonMessage> {
ObjectWriter<?> objectWriter = creator.createObjectWriter(StringMessage.class); ObjectWriter<?> objectWriter = creator.createObjectWriter(StringMessage.class);
objectWriter.write(jsonWriter, messagePart); objectWriter.write(jsonWriter, messagePart);
} else { } else {
jsonWriter.writeAny(messagePart); new JsonMessagePartWriter().write(jsonWriter, messagePart);
} }
if (i != size - 1) { if (i != size - 1) {
jsonWriter.writeComma(); jsonWriter.writeComma();

View File

@ -1,4 +1,9 @@
network:
websocket: "<Your WebSocket connection link, e.g: ws://127.0.0.1:3001/>" websocket: "<Your WebSocket connection link, e.g: ws://127.0.0.1:3001/>"
retry: true
maxRetryCount: 3
retryInterval: 10000
commandPrefix: "/"
authorization: authorization:
enable: false enable: false
token: "<If you enable authorization, you should fill in this>" token: "<If you enable authorization, you should fill in this>"