Commit f9f8a4a6 authored by nanahira's avatar nanahira

catchup

parent 7b011ebc
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"lodash": "^4.17.21", "lodash": "^4.17.21",
"schemastery-gen": "^2.0.0", "schemastery-gen": "^2.2.4",
"source-map-support": "^0.5.20" "source-map-support": "^0.5.20"
}, },
"devDependencies": { "devDependencies": {
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
"eslint": "^7.32.0", "eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0", "eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.1", "eslint-plugin-prettier": "^3.4.1",
"koishi": "^4.0.0-beta.3", "koishi": "^4.0.0-beta.4",
"prettier": "^2.4.1", "prettier": "^2.4.1",
"raw-loader": "^4.0.2", "raw-loader": "^4.0.2",
"ts-loader": "^9.2.6", "ts-loader": "^9.2.6",
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
"webpack-cli": "^4.9.1" "webpack-cli": "^4.9.1"
}, },
"peerDependencies": { "peerDependencies": {
"koishi": "^4.0.0-beta.3" "koishi": "^4.0.0-beta.4"
} }
}, },
"node_modules/@babel/code-frame": { "node_modules/@babel/code-frame": {
...@@ -211,31 +211,19 @@ ...@@ -211,31 +211,19 @@
} }
}, },
"node_modules/@koishijs/core": { "node_modules/@koishijs/core": {
"version": "4.0.0-beta.3", "version": "4.0.0-beta.4",
"resolved": "https://registry.npmjs.org/@koishijs/core/-/core-4.0.0-beta.3.tgz", "resolved": "https://registry.npmjs.org/@koishijs/core/-/core-4.0.0-beta.4.tgz",
"integrity": "sha512-ZCdjZOQ4yNN49/LdOzHKo61j/S+GwqckM116tXrZYF7gNHRZ5486HFJqJjYDCYO3n2AZvQ4nV6w8OSaoIXIPEQ==", "integrity": "sha512-i+66ZR3mSAIm1pJmC21QID8QhqJDdJ7zmZ8pCn3mPcfZFGiwL8MDMvwuDvG2ceCyILmtzmXwstURrc2tjB+QPg==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@koishijs/utils": "^5.0.0-beta.1", "@koishijs/utils": "^5.0.0-beta.1",
"fastest-levenshtein": "^1.0.12", "fastest-levenshtein": "^1.0.12",
"schemastery": "^2.0.0" "schemastery": "^2.1.0"
}, },
"engines": { "engines": {
"node": ">=12.0.0" "node": ">=12.0.0"
} }
}, },
"node_modules/@koishijs/plugin-cache-lru": {
"version": "1.0.0-beta.2",
"resolved": "https://registry.npmjs.org/@koishijs/plugin-cache-lru/-/plugin-cache-lru-1.0.0-beta.2.tgz",
"integrity": "sha512-RkLf6Gb+bvJcfBv9ZtfsEFo7NcCr+buQgiKccllfU5rANvUW5uXlPmjcTmV6AaKAr7fDZsCR3GRusiJtzS7STQ==",
"dev": true,
"dependencies": {
"lru-cache": "^6.0.0"
},
"peerDependencies": {
"koishi": "^4.0.0-beta.3"
}
},
"node_modules/@koishijs/utils": { "node_modules/@koishijs/utils": {
"version": "5.0.0-beta.1", "version": "5.0.0-beta.1",
"resolved": "https://registry.npmjs.org/@koishijs/utils/-/utils-5.0.0-beta.1.tgz", "resolved": "https://registry.npmjs.org/@koishijs/utils/-/utils-5.0.0-beta.1.tgz",
...@@ -2697,14 +2685,13 @@ ...@@ -2697,14 +2685,13 @@
} }
}, },
"node_modules/koishi": { "node_modules/koishi": {
"version": "4.0.0-beta.3", "version": "4.0.0-beta.4",
"resolved": "https://registry.npmjs.org/koishi/-/koishi-4.0.0-beta.3.tgz", "resolved": "https://registry.npmjs.org/koishi/-/koishi-4.0.0-beta.4.tgz",
"integrity": "sha512-sWTOU4maJnsRU7w8Upw8rBT1aZ0zEfN9Cs02tR2UP7qdmZiRTyrjWWFElaMhmnoj+6nTH7Udihmwb4MwbBimfA==", "integrity": "sha512-H0ci/bZ+wHDCnNmLFM125RI+cdprz3McJLEbyK43tGsGuf2y13BuFb+j1ovb6FBRuT3SXlDqH+BpVMlCV2ZaVg==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@koa/router": "^10.1.1", "@koa/router": "^10.1.1",
"@koishijs/core": "^4.0.0-beta.3", "@koishijs/core": "^4.0.0-beta.4",
"@koishijs/plugin-cache-lru": "^1.0.0-beta.2",
"@koishijs/utils": "^5.0.0-beta.1", "@koishijs/utils": "^5.0.0-beta.1",
"@types/koa": "*", "@types/koa": "*",
"@types/koa__router": "*", "@types/koa__router": "*",
...@@ -3567,21 +3554,21 @@ ...@@ -3567,21 +3554,21 @@
} }
}, },
"node_modules/schemastery": { "node_modules/schemastery": {
"version": "2.0.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/schemastery/-/schemastery-2.0.0.tgz", "resolved": "https://registry.npmjs.org/schemastery/-/schemastery-2.1.0.tgz",
"integrity": "sha512-g628Fvc8cY3Laoyz+v45qZGiClwhTj0MsiGF+tSVlUh+hqYf6kVkTaWdIHNGhfj11h9QzRrs0A4wfvQZuHg3iA==" "integrity": "sha512-D5wGNn5lc8GnhTzSl2ClH6RwUB69NMUrIXn6qWJVZSSq1fJtEodL9zXoJUbzoLQlL7rGMuO6entajhZvJY25Tw=="
}, },
"node_modules/schemastery-gen": { "node_modules/schemastery-gen": {
"version": "2.0.0", "version": "2.2.4",
"resolved": "https://registry.npmjs.org/schemastery-gen/-/schemastery-gen-2.0.0.tgz", "resolved": "https://registry.npmjs.org/schemastery-gen/-/schemastery-gen-2.2.4.tgz",
"integrity": "sha512-lTttqIWwNM8nizqUpUvJOERtb+Su4qkNe5Lp0ruINiZlCuN/HBCAOmf+OcdAlWLW8BRAY+xIzf4o1Kl043HVVQ==", "integrity": "sha512-WHneTi+RSo28DRMV/Nxspw/Vyv0c2vExBNskxRTdf/Dik6ZTwF4cC5y9eSas+99kctqgxJKBBBcf9vp9mqPYzQ==",
"dependencies": { "dependencies": {
"lodash": "^4.17.21", "lodash": "^4.17.21",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"typed-reflector": "^1.0.5" "typed-reflector": "^1.0.8"
}, },
"peerDependencies": { "peerDependencies": {
"schemastery": "^2.0.0" "schemastery": "^2.1.0"
} }
}, },
"node_modules/semver": { "node_modules/semver": {
...@@ -4051,9 +4038,9 @@ ...@@ -4051,9 +4038,9 @@
} }
}, },
"node_modules/typed-reflector": { "node_modules/typed-reflector": {
"version": "1.0.5", "version": "1.0.8",
"resolved": "https://registry.npmjs.org/typed-reflector/-/typed-reflector-1.0.5.tgz", "resolved": "https://registry.npmjs.org/typed-reflector/-/typed-reflector-1.0.8.tgz",
"integrity": "sha512-uVXjRyfia44NftErLxahyXgXN2C9GhLtFvVnUxdjwU4fRn0dFI+MbqEKy8oYAMdVkC8xRh8xm3r4w/C1aYZMXg==", "integrity": "sha512-Gc2y1jdXpBrRDhTth80ABcmZjL/4Jmx+GrBf7uvn4BXW4J+kj5V3IjA+GQl/n+3ye7SgoEO6HOiDhac1H+mKgw==",
"dependencies": { "dependencies": {
"reflect-metadata": "^0.1.13" "reflect-metadata": "^0.1.13"
} }
...@@ -4500,23 +4487,14 @@ ...@@ -4500,23 +4487,14 @@
} }
}, },
"@koishijs/core": { "@koishijs/core": {
"version": "4.0.0-beta.3", "version": "4.0.0-beta.4",
"resolved": "https://registry.npmjs.org/@koishijs/core/-/core-4.0.0-beta.3.tgz", "resolved": "https://registry.npmjs.org/@koishijs/core/-/core-4.0.0-beta.4.tgz",
"integrity": "sha512-ZCdjZOQ4yNN49/LdOzHKo61j/S+GwqckM116tXrZYF7gNHRZ5486HFJqJjYDCYO3n2AZvQ4nV6w8OSaoIXIPEQ==", "integrity": "sha512-i+66ZR3mSAIm1pJmC21QID8QhqJDdJ7zmZ8pCn3mPcfZFGiwL8MDMvwuDvG2ceCyILmtzmXwstURrc2tjB+QPg==",
"dev": true, "dev": true,
"requires": { "requires": {
"@koishijs/utils": "^5.0.0-beta.1", "@koishijs/utils": "^5.0.0-beta.1",
"fastest-levenshtein": "^1.0.12", "fastest-levenshtein": "^1.0.12",
"schemastery": "^2.0.0" "schemastery": "^2.1.0"
}
},
"@koishijs/plugin-cache-lru": {
"version": "1.0.0-beta.2",
"resolved": "https://registry.npmjs.org/@koishijs/plugin-cache-lru/-/plugin-cache-lru-1.0.0-beta.2.tgz",
"integrity": "sha512-RkLf6Gb+bvJcfBv9ZtfsEFo7NcCr+buQgiKccllfU5rANvUW5uXlPmjcTmV6AaKAr7fDZsCR3GRusiJtzS7STQ==",
"dev": true,
"requires": {
"lru-cache": "^6.0.0"
} }
}, },
"@koishijs/utils": { "@koishijs/utils": {
...@@ -6425,14 +6403,13 @@ ...@@ -6425,14 +6403,13 @@
} }
}, },
"koishi": { "koishi": {
"version": "4.0.0-beta.3", "version": "4.0.0-beta.4",
"resolved": "https://registry.npmjs.org/koishi/-/koishi-4.0.0-beta.3.tgz", "resolved": "https://registry.npmjs.org/koishi/-/koishi-4.0.0-beta.4.tgz",
"integrity": "sha512-sWTOU4maJnsRU7w8Upw8rBT1aZ0zEfN9Cs02tR2UP7qdmZiRTyrjWWFElaMhmnoj+6nTH7Udihmwb4MwbBimfA==", "integrity": "sha512-H0ci/bZ+wHDCnNmLFM125RI+cdprz3McJLEbyK43tGsGuf2y13BuFb+j1ovb6FBRuT3SXlDqH+BpVMlCV2ZaVg==",
"dev": true, "dev": true,
"requires": { "requires": {
"@koa/router": "^10.1.1", "@koa/router": "^10.1.1",
"@koishijs/core": "^4.0.0-beta.3", "@koishijs/core": "^4.0.0-beta.4",
"@koishijs/plugin-cache-lru": "^1.0.0-beta.2",
"@koishijs/utils": "^5.0.0-beta.1", "@koishijs/utils": "^5.0.0-beta.1",
"@types/koa": "*", "@types/koa": "*",
"@types/koa__router": "*", "@types/koa__router": "*",
...@@ -7074,18 +7051,18 @@ ...@@ -7074,18 +7051,18 @@
} }
}, },
"schemastery": { "schemastery": {
"version": "2.0.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/schemastery/-/schemastery-2.0.0.tgz", "resolved": "https://registry.npmjs.org/schemastery/-/schemastery-2.1.0.tgz",
"integrity": "sha512-g628Fvc8cY3Laoyz+v45qZGiClwhTj0MsiGF+tSVlUh+hqYf6kVkTaWdIHNGhfj11h9QzRrs0A4wfvQZuHg3iA==" "integrity": "sha512-D5wGNn5lc8GnhTzSl2ClH6RwUB69NMUrIXn6qWJVZSSq1fJtEodL9zXoJUbzoLQlL7rGMuO6entajhZvJY25Tw=="
}, },
"schemastery-gen": { "schemastery-gen": {
"version": "2.0.0", "version": "2.2.4",
"resolved": "https://registry.npmjs.org/schemastery-gen/-/schemastery-gen-2.0.0.tgz", "resolved": "https://registry.npmjs.org/schemastery-gen/-/schemastery-gen-2.2.4.tgz",
"integrity": "sha512-lTttqIWwNM8nizqUpUvJOERtb+Su4qkNe5Lp0ruINiZlCuN/HBCAOmf+OcdAlWLW8BRAY+xIzf4o1Kl043HVVQ==", "integrity": "sha512-WHneTi+RSo28DRMV/Nxspw/Vyv0c2vExBNskxRTdf/Dik6ZTwF4cC5y9eSas+99kctqgxJKBBBcf9vp9mqPYzQ==",
"requires": { "requires": {
"lodash": "^4.17.21", "lodash": "^4.17.21",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"typed-reflector": "^1.0.5" "typed-reflector": "^1.0.8"
} }
}, },
"semver": { "semver": {
...@@ -7423,9 +7400,9 @@ ...@@ -7423,9 +7400,9 @@
} }
}, },
"typed-reflector": { "typed-reflector": {
"version": "1.0.5", "version": "1.0.8",
"resolved": "https://registry.npmjs.org/typed-reflector/-/typed-reflector-1.0.5.tgz", "resolved": "https://registry.npmjs.org/typed-reflector/-/typed-reflector-1.0.8.tgz",
"integrity": "sha512-uVXjRyfia44NftErLxahyXgXN2C9GhLtFvVnUxdjwU4fRn0dFI+MbqEKy8oYAMdVkC8xRh8xm3r4w/C1aYZMXg==", "integrity": "sha512-Gc2y1jdXpBrRDhTth80ABcmZjL/4Jmx+GrBf7uvn4BXW4J+kj5V3IjA+GQl/n+3ye7SgoEO6HOiDhac1H+mKgw==",
"requires": { "requires": {
"reflect-metadata": "^0.1.13" "reflect-metadata": "^0.1.13"
} }
......
...@@ -26,11 +26,11 @@ ...@@ -26,11 +26,11 @@
"homepage": "https://code.mycard.moe/3rdeye/koishi-plugin-thesaurus", "homepage": "https://code.mycard.moe/3rdeye/koishi-plugin-thesaurus",
"dependencies": { "dependencies": {
"lodash": "^4.17.21", "lodash": "^4.17.21",
"schemastery-gen": "^2.0.0", "schemastery-gen": "^2.2.4",
"source-map-support": "^0.5.20" "source-map-support": "^0.5.20"
}, },
"peerDependencies": { "peerDependencies": {
"koishi": "^4.0.0-beta.3" "koishi": "^4.0.0-beta.4"
}, },
"devDependencies": { "devDependencies": {
"@types/lodash": "^4.14.175", "@types/lodash": "^4.14.175",
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
"eslint": "^7.32.0", "eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0", "eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.1", "eslint-plugin-prettier": "^3.4.1",
"koishi": "^4.0.0-beta.3", "koishi": "^4.0.0-beta.4",
"prettier": "^2.4.1", "prettier": "^2.4.1",
"raw-loader": "^4.0.2", "raw-loader": "^4.0.2",
"ts-loader": "^9.2.6", "ts-loader": "^9.2.6",
......
...@@ -4,26 +4,26 @@ import { DefineSchema, RegisterSchema } from 'schemastery-gen'; ...@@ -4,26 +4,26 @@ import { DefineSchema, RegisterSchema } from 'schemastery-gen';
@RegisterSchema() @RegisterSchema()
export class MyPluginConfig { export class MyPluginConfig {
@DefineSchema({ @DefineSchema({
desc: '词库本地路径或 URL。', description: '词库本地路径或 URL。',
default: default:
'https://code.mycard.moe/3rdeye/AnimeThesaurus/-/raw/main/data.json', 'https://code.mycard.moe/3rdeye/AnimeThesaurus/-/raw/main/data.json',
}) })
path: string; path: string;
@DefineSchema({ @DefineSchema({
desc: '聊天超时时间 ms。', description: '聊天超时时间 ms。',
default: 600000, default: 600000,
}) })
chatTimeout: number; chatTimeout: number;
@DefineSchema({ @DefineSchema({
desc: '追溯会话长度', description: '追溯会话长度',
default: 10, default: 10,
}) })
trackingLength: number; trackingLength: number;
@DefineSchema({ @DefineSchema({
desc: '从数据库获取用户名。', description: '从数据库获取用户名。',
default: false, default: false,
}) })
useDatabase: boolean; useDatabase: boolean;
......
...@@ -14,6 +14,7 @@ declare module 'koishi' { ...@@ -14,6 +14,7 @@ declare module 'koishi' {
export const name = 'thesaurus'; export const name = 'thesaurus';
const plugin = new MyPlugin(); const plugin = new MyPlugin();
export const schema = plugin.schema; export const schema = plugin.schema;
export const using = ['cache'];
export function apply(ctx: Context, config: MyPluginConfig) { export function apply(ctx: Context, config: MyPluginConfig) {
ctx.plugin(plugin, config); ctx.plugin(plugin, config);
} }
...@@ -146,11 +146,11 @@ export class MyPlugin { ...@@ -146,11 +146,11 @@ export class MyPlugin {
async apply(ctx: Context, config: MyPluginConfig) { async apply(ctx: Context, config: MyPluginConfig) {
this.ctx = ctx; this.ctx = ctx;
this.config = config; this.config = config;
ctx.on('service/database', () => { ctx.on('service', (name) => {
if (this.config.useDatabase) this.useDatabase = !!ctx.database; if (this.config.useDatabase && name === 'database') this.useDatabase = !!ctx.database;
}); });
ctx.on('service/cache', () => { ctx.on('service', (name) => {
if (!ctx.cache) { if (!ctx.cache || name !== 'cache') {
return; return;
} }
ctx.cache.table('thesaurusChatSession', { ctx.cache.table('thesaurusChatSession', {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment